summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ecdsa/ecs_sign.c
diff options
context:
space:
mode:
authorjsing <>2015-02-08 13:35:07 +0000
committerjsing <>2015-02-08 13:35:07 +0000
commit726b51738f080413928933335c86b6b01cf96864 (patch)
tree5a291cb11bb8d4fde0d4d335440fe8cad504b4c4 /src/lib/libcrypto/ecdsa/ecs_sign.c
parentf5656e5948afd96eceeae5f83939965ba96edc28 (diff)
downloadopenbsd-726b51738f080413928933335c86b6b01cf96864.tar.gz
openbsd-726b51738f080413928933335c86b6b01cf96864.tar.bz2
openbsd-726b51738f080413928933335c86b6b01cf96864.zip
Lob a KNF grenade into the ecdsa code.
Diffstat (limited to '')
-rw-r--r--src/lib/libcrypto/ecdsa/ecs_sign.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/lib/libcrypto/ecdsa/ecs_sign.c b/src/lib/libcrypto/ecdsa/ecs_sign.c
index 55bb02d57f..029a0cb562 100644
--- a/src/lib/libcrypto/ecdsa/ecs_sign.c
+++ b/src/lib/libcrypto/ecdsa/ecs_sign.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecs_sign.c,v 1.5 2014/10/18 17:20:40 jsing Exp $ */ 1/* $OpenBSD: ecs_sign.c,v 1.6 2015/02/08 13:35:07 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -7,7 +7,7 @@
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 11 *
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in 13 * notice, this list of conditions and the following disclaimer in
@@ -60,35 +60,39 @@
60#include <openssl/engine.h> 60#include <openssl/engine.h>
61#endif 61#endif
62 62
63ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) 63ECDSA_SIG *
64ECDSA_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey)
64{ 65{
65 return ECDSA_do_sign_ex(dgst, dlen, NULL, NULL, eckey); 66 return ECDSA_do_sign_ex(dgst, dlen, NULL, NULL, eckey);
66} 67}
67 68
68ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dlen, 69ECDSA_SIG *
69 const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey) 70ECDSA_do_sign_ex(const unsigned char *dgst, int dlen, const BIGNUM *kinv,
71 const BIGNUM *rp, EC_KEY *eckey)
70{ 72{
71 ECDSA_DATA *ecdsa = ecdsa_check(eckey); 73 ECDSA_DATA *ecdsa = ecdsa_check(eckey);
74
72 if (ecdsa == NULL) 75 if (ecdsa == NULL)
73 return NULL; 76 return NULL;
74 return ecdsa->meth->ecdsa_do_sign(dgst, dlen, kinv, rp, eckey); 77 return ecdsa->meth->ecdsa_do_sign(dgst, dlen, kinv, rp, eckey);
75} 78}
76 79
77int ECDSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char 80int
78 *sig, unsigned int *siglen, EC_KEY *eckey) 81ECDSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig,
82 unsigned int *siglen, EC_KEY *eckey)
79{ 83{
80 return ECDSA_sign_ex(type, dgst, dlen, sig, siglen, NULL, NULL, eckey); 84 return ECDSA_sign_ex(type, dgst, dlen, sig, siglen, NULL, NULL, eckey);
81} 85}
82 86
83int ECDSA_sign_ex(int type, const unsigned char *dgst, int dlen, unsigned char 87int
84 *sig, unsigned int *siglen, const BIGNUM *kinv, const BIGNUM *r, 88ECDSA_sign_ex(int type, const unsigned char *dgst, int dlen, unsigned char *sig,
85 EC_KEY *eckey) 89 unsigned int *siglen, const BIGNUM *kinv, const BIGNUM *r, EC_KEY *eckey)
86{ 90{
87 ECDSA_SIG *s; 91 ECDSA_SIG *s;
92
88 s = ECDSA_do_sign_ex(dgst, dlen, kinv, r, eckey); 93 s = ECDSA_do_sign_ex(dgst, dlen, kinv, r, eckey);
89 if (s == NULL) 94 if (s == NULL) {
90 { 95 *siglen = 0;
91 *siglen=0;
92 return 0; 96 return 0;
93 } 97 }
94 *siglen = i2d_ECDSA_SIG(s, &sig); 98 *siglen = i2d_ECDSA_SIG(s, &sig);
@@ -96,11 +100,12 @@ int ECDSA_sign_ex(int type, const unsigned char *dgst, int dlen, unsigned char
96 return 1; 100 return 1;
97} 101}
98 102
99int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, 103int
100 BIGNUM **rp) 104ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp)
101{ 105{
102 ECDSA_DATA *ecdsa = ecdsa_check(eckey); 106 ECDSA_DATA *ecdsa = ecdsa_check(eckey);
107
103 if (ecdsa == NULL) 108 if (ecdsa == NULL)
104 return 0; 109 return 0;
105 return ecdsa->meth->ecdsa_sign_setup(eckey, ctx_in, kinvp, rp); 110 return ecdsa->meth->ecdsa_sign_setup(eckey, ctx_in, kinvp, rp);
106} 111}