summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/rsa/rsa_sign.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/rsa/rsa_sign.c')
-rw-r--r--src/lib/libcrypto/rsa/rsa_sign.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_sign.c b/src/lib/libcrypto/rsa/rsa_sign.c
index 05bb7fb74a..cf00876292 100644
--- a/src/lib/libcrypto/rsa/rsa_sign.c
+++ b/src/lib/libcrypto/rsa/rsa_sign.c
@@ -62,6 +62,7 @@
62#include <openssl/rsa.h> 62#include <openssl/rsa.h>
63#include <openssl/objects.h> 63#include <openssl/objects.h>
64#include <openssl/x509.h> 64#include <openssl/x509.h>
65#include <openssl/engine.h>
65 66
66/* Size of an SSL signature: MD5+SHA1 */ 67/* Size of an SSL signature: MD5+SHA1 */
67#define SSL_SIG_LENGTH 36 68#define SSL_SIG_LENGTH 36
@@ -76,7 +77,8 @@ int RSA_sign(int type, unsigned char *m, unsigned int m_len,
76 X509_ALGOR algor; 77 X509_ALGOR algor;
77 ASN1_OCTET_STRING digest; 78 ASN1_OCTET_STRING digest;
78 if(rsa->flags & RSA_FLAG_SIGN_VER) 79 if(rsa->flags & RSA_FLAG_SIGN_VER)
79 return rsa->meth->rsa_sign(type, m, m_len, sigret, siglen, rsa); 80 return ENGINE_get_RSA(rsa->engine)->rsa_sign(type,
81 m, m_len, sigret, siglen, rsa);
80 /* Special case: SSL signature, just check the length */ 82 /* Special case: SSL signature, just check the length */
81 if(type == NID_md5_sha1) { 83 if(type == NID_md5_sha1) {
82 if(m_len != SSL_SIG_LENGTH) { 84 if(m_len != SSL_SIG_LENGTH) {
@@ -115,7 +117,7 @@ int RSA_sign(int type, unsigned char *m, unsigned int m_len,
115 return(0); 117 return(0);
116 } 118 }
117 if(type != NID_md5_sha1) { 119 if(type != NID_md5_sha1) {
118 s=(unsigned char *)Malloc((unsigned int)j+1); 120 s=(unsigned char *)OPENSSL_malloc((unsigned int)j+1);
119 if (s == NULL) 121 if (s == NULL)
120 { 122 {
121 RSAerr(RSA_F_RSA_SIGN,ERR_R_MALLOC_FAILURE); 123 RSAerr(RSA_F_RSA_SIGN,ERR_R_MALLOC_FAILURE);
@@ -132,7 +134,7 @@ int RSA_sign(int type, unsigned char *m, unsigned int m_len,
132 134
133 if(type != NID_md5_sha1) { 135 if(type != NID_md5_sha1) {
134 memset(s,0,(unsigned int)j+1); 136 memset(s,0,(unsigned int)j+1);
135 Free(s); 137 OPENSSL_free(s);
136 } 138 }
137 return(ret); 139 return(ret);
138 } 140 }
@@ -151,9 +153,10 @@ int RSA_verify(int dtype, unsigned char *m, unsigned int m_len,
151 } 153 }
152 154
153 if(rsa->flags & RSA_FLAG_SIGN_VER) 155 if(rsa->flags & RSA_FLAG_SIGN_VER)
154 return rsa->meth->rsa_verify(dtype, m, m_len, sigbuf, siglen, rsa); 156 return ENGINE_get_RSA(rsa->engine)->rsa_verify(dtype,
157 m, m_len, sigbuf, siglen, rsa);
155 158
156 s=(unsigned char *)Malloc((unsigned int)siglen); 159 s=(unsigned char *)OPENSSL_malloc((unsigned int)siglen);
157 if (s == NULL) 160 if (s == NULL)
158 { 161 {
159 RSAerr(RSA_F_RSA_VERIFY,ERR_R_MALLOC_FAILURE); 162 RSAerr(RSA_F_RSA_VERIFY,ERR_R_MALLOC_FAILURE);
@@ -215,7 +218,7 @@ int RSA_verify(int dtype, unsigned char *m, unsigned int m_len,
215err: 218err:
216 if (sig != NULL) X509_SIG_free(sig); 219 if (sig != NULL) X509_SIG_free(sig);
217 memset(s,0,(unsigned int)siglen); 220 memset(s,0,(unsigned int)siglen);
218 Free(s); 221 OPENSSL_free(s);
219 return(ret); 222 return(ret);
220 } 223 }
221 224