summaryrefslogtreecommitdiffstats
path: root/crypto/evp
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>1999-10-25 04:00:09 +0200
committerDr. Stephen Henson <steve@openssl.org>1999-10-25 04:00:09 +0200
commitf769ce3ea41ba1c2b16f345722ed006861d51150 (patch)
tree5df2c631989beff5b5b28f01cc09c6c12e44ce02 /crypto/evp
parentConstification. (diff)
downloadopenssl-f769ce3ea41ba1c2b16f345722ed006861d51150.tar.xz
openssl-f769ce3ea41ba1c2b16f345722ed006861d51150.zip
More multibyte character support.
Functions to get keys from EVP_PKEY structures.
Diffstat (limited to 'crypto/evp')
-rw-r--r--crypto/evp/evp.h9
-rw-r--r--crypto/evp/evp_err.c6
-rw-r--r--crypto/evp/p_lib.c36
3 files changed, 51 insertions, 0 deletions
diff --git a/crypto/evp/evp.h b/crypto/evp/evp.h
index 95ead04764..f249daeed6 100644
--- a/crypto/evp/evp.h
+++ b/crypto/evp/evp.h
@@ -612,6 +612,9 @@ int EVP_PKEY_type(int type);
int EVP_PKEY_bits(EVP_PKEY *pkey);
int EVP_PKEY_size(EVP_PKEY *pkey);
int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key);
+RSA * EVP_PKEY_get_RSA(EVP_PKEY *pkey);
+DSA * EVP_PKEY_get_DSA(EVP_PKEY *pkey);
+DH * EVP_PKEY_get_DH(EVP_PKEY *pkey);
EVP_PKEY * EVP_PKEY_new(void);
void EVP_PKEY_free(EVP_PKEY *pkey);
EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, unsigned char **pp,
@@ -676,6 +679,9 @@ void EVP_PBE_cleanup(void);
#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103
#define EVP_F_EVP_PKEY_DECRYPT 104
#define EVP_F_EVP_PKEY_ENCRYPT 105
+#define EVP_F_EVP_PKEY_GET_DH 119
+#define EVP_F_EVP_PKEY_GET_DSA 120
+#define EVP_F_EVP_PKEY_GET_RSA 121
#define EVP_F_EVP_PKEY_NEW 106
#define EVP_F_EVP_SIGNFINAL 107
#define EVP_F_EVP_VERIFYFINAL 108
@@ -692,6 +698,9 @@ void EVP_PBE_cleanup(void);
#define EVP_R_DIFFERENT_KEY_TYPES 101
#define EVP_R_ENCODE_ERROR 115
#define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119
+#define EVP_R_EXPECTING_AN_RSA_KEY 127
+#define EVP_R_EXPECTING_A_DH_KEY 128
+#define EVP_R_EXPECTING_A_DSA_KEY 129
#define EVP_R_INPUT_NOT_INITIALIZED 111
#define EVP_R_IV_TOO_LARGE 102
#define EVP_R_KEYGEN_FAILURE 120
diff --git a/crypto/evp/evp_err.c b/crypto/evp/evp_err.c
index c61cc922e8..7d21938ec5 100644
--- a/crypto/evp/evp_err.c
+++ b/crypto/evp/evp_err.c
@@ -77,6 +77,9 @@ static ERR_STRING_DATA EVP_str_functs[]=
{ERR_PACK(0,EVP_F_EVP_PKEY_COPY_PARAMETERS,0), "EVP_PKEY_copy_parameters"},
{ERR_PACK(0,EVP_F_EVP_PKEY_DECRYPT,0), "EVP_PKEY_decrypt"},
{ERR_PACK(0,EVP_F_EVP_PKEY_ENCRYPT,0), "EVP_PKEY_encrypt"},
+{ERR_PACK(0,EVP_F_EVP_PKEY_GET_DH,0), "EVP_PKEY_get_DH"},
+{ERR_PACK(0,EVP_F_EVP_PKEY_GET_DSA,0), "EVP_PKEY_get_DSA"},
+{ERR_PACK(0,EVP_F_EVP_PKEY_GET_RSA,0), "EVP_PKEY_get_RSA"},
{ERR_PACK(0,EVP_F_EVP_PKEY_NEW,0), "EVP_PKEY_new"},
{ERR_PACK(0,EVP_F_EVP_SIGNFINAL,0), "EVP_SignFinal"},
{ERR_PACK(0,EVP_F_EVP_VERIFYFINAL,0), "EVP_VerifyFinal"},
@@ -96,6 +99,9 @@ static ERR_STRING_DATA EVP_str_reasons[]=
{EVP_R_DIFFERENT_KEY_TYPES ,"different key types"},
{EVP_R_ENCODE_ERROR ,"encode error"},
{EVP_R_EVP_PBE_CIPHERINIT_ERROR ,"evp pbe cipherinit error"},
+{EVP_R_EXPECTING_AN_RSA_KEY ,"expecting an rsa key"},
+{EVP_R_EXPECTING_A_DH_KEY ,"expecting a dh key"},
+{EVP_R_EXPECTING_A_DSA_KEY ,"expecting a dsa key"},
{EVP_R_INPUT_NOT_INITIALIZED ,"input not initialized"},
{EVP_R_IV_TOO_LARGE ,"iv too large"},
{EVP_R_KEYGEN_FAILURE ,"keygen failure"},
diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c
index 3422b77de6..dba08525a3 100644
--- a/crypto/evp/p_lib.c
+++ b/crypto/evp/p_lib.c
@@ -205,6 +205,42 @@ int EVP_PKEY_assign(EVP_PKEY *pkey, int type, char *key)
return(1);
}
+#ifndef NO_RSA
+RSA *EVP_PKEY_get_RSA(EVP_PKEY *pkey)
+ {
+ if(pkey->type != EVP_PKEY_RSA) {
+ EVPerr(EVP_F_EVP_PKEY_GET_RSA, EVP_R_EXPECTING_AN_RSA_KEY);
+ return NULL;
+ }
+ CRYPTO_add(&pkey->pkey.rsa->references, 1, CRYPTO_LOCK_RSA);
+ return pkey->pkey.rsa;
+}
+#endif
+
+#ifndef NO_DSA
+DSA *EVP_PKEY_get_DSA(EVP_PKEY *pkey)
+ {
+ if(pkey->type != EVP_PKEY_DSA) {
+ EVPerr(EVP_F_EVP_PKEY_GET_DSA, EVP_R_EXPECTING_A_DSA_KEY);
+ return NULL;
+ }
+ CRYPTO_add(&pkey->pkey.rsa->references, 1, CRYPTO_LOCK_DSA);
+ return pkey->pkey.dsa;
+}
+#endif
+
+#ifndef NO_DH
+DH *EVP_PKEY_get_DH(EVP_PKEY *pkey)
+ {
+ if(pkey->type != EVP_PKEY_DH) {
+ EVPerr(EVP_F_EVP_PKEY_GET_DH, EVP_R_EXPECTING_A_DH_KEY);
+ return NULL;
+ }
+ CRYPTO_add(&pkey->pkey.dh->references, 1, CRYPTO_LOCK_DH);
+ return pkey->pkey.dh;
+}
+#endif
+
int EVP_PKEY_type(int type)
{
switch (type)