summaryrefslogtreecommitdiffstats
path: root/crypto/evp/p_lib.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2003-04-03 22:27:24 +0000
committerRichard Levitte <levitte@openssl.org>2003-04-03 22:27:24 +0000
commite6526fbf4dc894d71ae3517a1ba484475b79b402 (patch)
treee852ebe778b4b013f0e783dc3547c60008d0dd60 /crypto/evp/p_lib.c
parent8152d887992c8f15fcf63c7da48c5d8805f1b3b2 (diff)
Add functionality to help making self-signed certificate.
Diffstat (limited to 'crypto/evp/p_lib.c')
-rw-r--r--crypto/evp/p_lib.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c
index c7a3dee108..8d23c0bd72 100644
--- a/crypto/evp/p_lib.c
+++ b/crypto/evp/p_lib.c
@@ -237,6 +237,52 @@ int EVP_PKEY_cmp_parameters(EVP_PKEY *a, EVP_PKEY *b)
return(-1);
}
+int EVP_PKEY_cmp(EVP_PKEY *a, EVP_PKEY *b)
+ {
+ if (a->type != b->type)
+ return -1;
+
+ switch (a->type)
+ {
+#ifndef OPENSSL_NO_RSA
+ case EVP_PKEY_RSA:
+ if (BN_cmp(b->pkey.rsa->n,a->pkey.rsa->n) != 0
+ || BN_cmp(b->pkey.rsa->e,a->pkey.rsa->e) != 0)
+ return 0;
+ break;
+#endif
+#ifndef OPENSSL_NO_DSA
+ case EVP_PKEY_DSA:
+ if (BN_cmp(b->pkey.dsa->pub_key,a->pkey.dsa->pub_key) != 0)
+ return 0;
+ break;
+#endif
+#ifndef OPENSSL_NO_EC
+ case EVP_PKEY_EC:
+ {
+ int r = EC_POINT_cmp(b->pkey.eckey->group,
+ b->pkey.eckey->pub_key,a->pkey.eckey->pub_key,NULL);
+ if (r != 0)
+ {
+ if (r == 1)
+ return 0;
+ else
+ return -2;
+ }
+ }
+ break;
+#endif
+#ifndef OPENSSL_NO_DH
+ case EVP_PKEY_DH:
+ return -2;
+#endif
+ default:
+ return -2;
+ }
+
+ return 1;
+ }
+
EVP_PKEY *EVP_PKEY_new(void)
{
EVP_PKEY *ret;