summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/a_sign.c
diff options
context:
space:
mode:
authortedu <>2014-04-18 00:10:08 +0000
committertedu <>2014-04-18 00:10:08 +0000
commit07f5c09b19f56c323fa22ebd5efb5a4df9f5dc4d (patch)
tree6327d50d69a1982f840dc68fe928ea459e2c41e0 /src/lib/libcrypto/asn1/a_sign.c
parent288a9e368d9d4a72792b12a00ad69e3592d94073 (diff)
downloadopenbsd-07f5c09b19f56c323fa22ebd5efb5a4df9f5dc4d.tar.gz
openbsd-07f5c09b19f56c323fa22ebd5efb5a4df9f5dc4d.tar.bz2
openbsd-07f5c09b19f56c323fa22ebd5efb5a4df9f5dc4d.zip
putting most of the braces in the right column is the very least we can do.
Diffstat (limited to 'src/lib/libcrypto/asn1/a_sign.c')
-rw-r--r--src/lib/libcrypto/asn1/a_sign.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/lib/libcrypto/asn1/a_sign.c b/src/lib/libcrypto/asn1/a_sign.c
index 0433b49a64..349422fe9a 100644
--- a/src/lib/libcrypto/asn1/a_sign.c
+++ b/src/lib/libcrypto/asn1/a_sign.c
@@ -128,22 +128,22 @@
128int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2, 128int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, X509_ALGOR *algor2,
129 ASN1_BIT_STRING *signature, void *asn, EVP_PKEY *pkey, 129 ASN1_BIT_STRING *signature, void *asn, EVP_PKEY *pkey,
130 const EVP_MD *type) 130 const EVP_MD *type)
131 { 131{
132 EVP_MD_CTX ctx; 132 EVP_MD_CTX ctx;
133 EVP_MD_CTX_init(&ctx); 133 EVP_MD_CTX_init(&ctx);
134 if (!EVP_DigestSignInit(&ctx, NULL, type, NULL, pkey)) 134 if (!EVP_DigestSignInit(&ctx, NULL, type, NULL, pkey))
135 { 135 {
136 EVP_MD_CTX_cleanup(&ctx); 136 EVP_MD_CTX_cleanup(&ctx);
137 return 0; 137 return 0;
138 }
139 return ASN1_item_sign_ctx(it, algor1, algor2, signature, asn, &ctx);
140 } 138 }
139 return ASN1_item_sign_ctx(it, algor1, algor2, signature, asn, &ctx);
140}
141 141
142 142
143int ASN1_item_sign_ctx(const ASN1_ITEM *it, 143int ASN1_item_sign_ctx(const ASN1_ITEM *it,
144 X509_ALGOR *algor1, X509_ALGOR *algor2, 144 X509_ALGOR *algor1, X509_ALGOR *algor2,
145 ASN1_BIT_STRING *signature, void *asn, EVP_MD_CTX *ctx) 145 ASN1_BIT_STRING *signature, void *asn, EVP_MD_CTX *ctx)
146 { 146{
147 const EVP_MD *type; 147 const EVP_MD *type;
148 EVP_PKEY *pkey; 148 EVP_PKEY *pkey;
149 unsigned char *buf_in=NULL,*buf_out=NULL; 149 unsigned char *buf_in=NULL,*buf_out=NULL;
@@ -155,13 +155,13 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it,
155 pkey = EVP_PKEY_CTX_get0_pkey(ctx->pctx); 155 pkey = EVP_PKEY_CTX_get0_pkey(ctx->pctx);
156 156
157 if (!type || !pkey) 157 if (!type || !pkey)
158 { 158 {
159 ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ASN1_R_CONTEXT_NOT_INITIALISED); 159 ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ASN1_R_CONTEXT_NOT_INITIALISED);
160 return 0; 160 return 0;
161 } 161 }
162 162
163 if (pkey->ameth->item_sign) 163 if (pkey->ameth->item_sign)
164 { 164 {
165 rv = pkey->ameth->item_sign(ctx, it, asn, algor1, algor2, 165 rv = pkey->ameth->item_sign(ctx, it, asn, algor1, algor2,
166 signature); 166 signature);
167 if (rv == 1) 167 if (rv == 1)
@@ -176,24 +176,24 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it,
176 ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ERR_R_EVP_LIB); 176 ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, ERR_R_EVP_LIB);
177 if (rv <= 1) 177 if (rv <= 1)
178 goto err; 178 goto err;
179 } 179 }
180 else 180 else
181 rv = 2; 181 rv = 2;
182 182
183 if (rv == 2) 183 if (rv == 2)
184 { 184 {
185 if (type->flags & EVP_MD_FLAG_PKEY_METHOD_SIGNATURE) 185 if (type->flags & EVP_MD_FLAG_PKEY_METHOD_SIGNATURE)
186 { 186 {
187 if (!pkey->ameth || 187 if (!pkey->ameth ||
188 !OBJ_find_sigid_by_algs(&signid, 188 !OBJ_find_sigid_by_algs(&signid,
189 EVP_MD_nid(type), 189 EVP_MD_nid(type),
190 pkey->ameth->pkey_id)) 190 pkey->ameth->pkey_id))
191 { 191 {
192 ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX, 192 ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX,
193 ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED); 193 ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED);
194 return 0; 194 return 0;
195 }
196 } 195 }
196 }
197 else 197 else
198 signid = type->pkey_type; 198 signid = type->pkey_type;
199 199
@@ -207,25 +207,25 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it,
207 if (algor2) 207 if (algor2)
208 X509_ALGOR_set0(algor2, OBJ_nid2obj(signid), paramtype, NULL); 208 X509_ALGOR_set0(algor2, OBJ_nid2obj(signid), paramtype, NULL);
209 209
210 } 210 }
211 211
212 inl=ASN1_item_i2d(asn,&buf_in, it); 212 inl=ASN1_item_i2d(asn,&buf_in, it);
213 outll=outl=EVP_PKEY_size(pkey); 213 outll=outl=EVP_PKEY_size(pkey);
214 buf_out=malloc((unsigned int)outl); 214 buf_out=malloc((unsigned int)outl);
215 if ((buf_in == NULL) || (buf_out == NULL)) 215 if ((buf_in == NULL) || (buf_out == NULL))
216 { 216 {
217 outl=0; 217 outl=0;
218 ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX,ERR_R_MALLOC_FAILURE); 218 ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX,ERR_R_MALLOC_FAILURE);
219 goto err; 219 goto err;
220 } 220 }
221 221
222 if (!EVP_DigestSignUpdate(ctx, buf_in, inl) 222 if (!EVP_DigestSignUpdate(ctx, buf_in, inl)
223 || !EVP_DigestSignFinal(ctx, buf_out, &outl)) 223 || !EVP_DigestSignFinal(ctx, buf_out, &outl))
224 { 224 {
225 outl=0; 225 outl=0;
226 ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX,ERR_R_EVP_LIB); 226 ASN1err(ASN1_F_ASN1_ITEM_SIGN_CTX,ERR_R_EVP_LIB);
227 goto err; 227 goto err;
228 } 228 }
229 if (signature->data != NULL) free(signature->data); 229 if (signature->data != NULL) free(signature->data);
230 signature->data=buf_out; 230 signature->data=buf_out;
231 buf_out=NULL; 231 buf_out=NULL;
@@ -238,8 +238,8 @@ int ASN1_item_sign_ctx(const ASN1_ITEM *it,
238err: 238err:
239 EVP_MD_CTX_cleanup(ctx); 239 EVP_MD_CTX_cleanup(ctx);
240 if (buf_in != NULL) 240 if (buf_in != NULL)
241 { OPENSSL_cleanse((char *)buf_in,(unsigned int)inl); free(buf_in); } 241 { OPENSSL_cleanse((char *)buf_in,(unsigned int)inl); free(buf_in); }
242 if (buf_out != NULL) 242 if (buf_out != NULL)
243 { OPENSSL_cleanse((char *)buf_out,outll); free(buf_out); } 243 { OPENSSL_cleanse((char *)buf_out,outll); free(buf_out); }
244 return(outl); 244 return(outl);
245 } 245}