More multibyte character support.
[openssl.git] / crypto / evp / p_lib.c
index 238dacccdca93fce1fe3951a22a2a2c6fb40ddbe..dba08525a35ab7b64a34c287e5b65e6c8120ca55 100644 (file)
 
 #include <stdio.h>
 #include "cryptlib.h"
-#include "objects.h"
-#include "evp.h"
-#include "asn1_mac.h"
-#include "x509.h"
+#include <openssl/objects.h>
+#include <openssl/evp.h>
+#include <openssl/asn1_mac.h>
+#include <openssl/x509.h>
 
-/* EVPerr(EVP_F_D2I_PKEY,EVP_R_UNSUPPORTED_CIPHER); */
-/* EVPerr(EVP_F_D2I_PKEY,EVP_R_IV_TOO_LARGE); */
-
-#ifndef NOPROTO
 static void EVP_PKEY_free_it(EVP_PKEY *x);
-#else
-static void EVP_PKEY_free_it();
-#endif
-
 int EVP_PKEY_bits(EVP_PKEY *pkey)
        {
 #ifndef NO_RSA
@@ -213,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)