Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

improved to get the public key by calling X509_get_pubkey()

  • Loading branch information...
commit 94b65f008232b72ca0f80206643bb65c59bd879c 1 parent e329478
sakane authored
View
32 kame/kame/racoon/crypto_openssl.c
@@ -1,4 +1,4 @@
-/* $KAME: crypto_openssl.c,v 1.83 2003/11/13 19:51:43 sakane Exp $ */
+/* $KAME: crypto_openssl.c,v 1.84 2004/04/07 01:12:46 sakane Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -661,7 +661,7 @@ eay_check_x509sign(source, sig, cert)
{
X509 *x509;
u_char *bp;
- vchar_t pubkey;
+ EVP_PKEY *evp;
bp = cert->v;
@@ -673,10 +673,16 @@ eay_check_x509sign(source, sig, cert)
return -1;
}
- pubkey.v = x509->cert_info->key->public_key->data;
- pubkey.l = x509->cert_info->key->public_key->length;
-
- return eay_rsa_verify(source, sig, &pubkey);
+ evp = X509_get_pubkey(x509);
+ if (!evp) {
+#ifndef EAYDEBUG
+ plog(LLV_ERROR, LOCATION, NULL,
+ "X509_get_pubkey: %s\n", eay_strerror());
+#endif
+ return -1;
+ }
+
+ return eay_rsa_verify(source, sig, evp);
}
/*
@@ -877,24 +883,16 @@ eay_rsa_sign(src, privkey)
}
int
-eay_rsa_verify(src, sig, pubkey)
- vchar_t *src, *sig, *pubkey;
-{
+eay_rsa_verify(src, sig, evp)
+ vchar_t *src, *sig;
EVP_PKEY *evp;
- u_char *bp = pubkey->v;
+{
vchar_t *xbuf = NULL;
int pad = RSA_PKCS1_PADDING;
int len = 0;
int error;
- evp = d2i_PUBKEY(NULL, &bp, pubkey->l);
- if (evp == NULL)
-#ifndef EAYDEBUG
- return 0;
-#endif
-
len = RSA_size(evp->pkey.rsa);
-
xbuf = vmalloc(len);
if (xbuf == NULL) {
#ifndef EAYDEBUG
View
4 kame/kame/racoon/crypto_openssl.h
@@ -1,4 +1,4 @@
-/* $KAME: crypto_openssl.h,v 1.28 2003/06/29 04:46:14 sakane Exp $ */
+/* $KAME: crypto_openssl.h,v 1.29 2004/04/07 01:12:46 sakane Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -57,7 +57,7 @@ extern int eay_check_pkcs7sign __P((vchar_t *, vchar_t *, vchar_t *));
/* RSA */
extern vchar_t *eay_rsa_sign __P((vchar_t *, vchar_t *));
-extern int eay_rsa_verify __P((vchar_t *, vchar_t *, vchar_t *));
+extern int eay_rsa_verify __P((vchar_t *, vchar_t *, EVP_PKEY *));
/* ASN.1 */
extern vchar_t *eay_get_pkcs1privkey __P((char *));
Please sign in to comment.
Something went wrong with that request. Please try again.