The inclusion of bn.h from the engine.h API header has been deprecated, so
[openssl.git] / engines / e_4758_cca.c
index 84de02df923041637589c87cf2ee5aaeb47fb149..262b373caaa1e44a958b64c7778063fa9d878f84 100644 (file)
 #include <stdio.h>
 #include <string.h>
 #include <openssl/crypto.h>
-/* #include <openssl/pem.h> */
 #include <openssl/dso.h>
 #include <openssl/x509.h>
 #include <openssl/objects.h>
 #include <openssl/engine.h>
+#include <openssl/rand.h>
+#include <openssl/rsa.h>
+#include <openssl/bn.h>
 
 #ifndef OPENSSL_NO_HW
 #ifndef OPENSSL_NO_HW_4758_CCA
@@ -76,7 +78,7 @@
 static int ibm_4758_cca_destroy(ENGINE *e);
 static int ibm_4758_cca_init(ENGINE *e);
 static int ibm_4758_cca_finish(ENGINE *e);
-static int ibm_4758_cca_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)());
+static int ibm_4758_cca_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void));
 
 /* rsa functions */
 /*---------------*/
@@ -182,7 +184,8 @@ static RSA_METHOD ibm_4758_cca_rsa =
        RSA_FLAG_SIGN_VER,        /* flags */
        NULL, /* app_data */
        cca_rsa_sign, /* rsa_sign */
-       cca_rsa_verify  /* rsa_verify */
+       cca_rsa_verify, /* rsa_verify */
+       NULL /* rsa_keygen */
        };
 #endif
 
@@ -342,7 +345,7 @@ static int ibm_4758_cca_finish(ENGINE *e)
        return 1;
        }
 
-static int ibm_4758_cca_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
+static int ibm_4758_cca_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
        {
        int initialised = ((dso == NULL) ? 0 : 1);
        switch(cmd)
@@ -389,7 +392,7 @@ static EVP_PKEY *ibm_4758_load_privkey(ENGINE* e, const char* key_id,
        unsigned char exitData[8];
        unsigned char ruleArray[8];
        unsigned char keyLabel[64];
-       long keyLabelLength = strlen(key_id);
+       unsigned long keyLabelLength = strlen(key_id);
        unsigned char modulus[256];
        long modulusFieldLength = sizeof(modulus);
        long modulusLength = 0;
@@ -481,7 +484,7 @@ static EVP_PKEY *ibm_4758_load_pubkey(ENGINE* e, const char* key_id,
        unsigned char exitData[8];
        unsigned char ruleArray[8];
        unsigned char keyLabel[64];
-       long keyLabelLength = strlen(key_id);
+       unsigned long keyLabelLength = strlen(key_id);
        unsigned char modulus[512];
        long modulusFieldLength = sizeof(modulus);
        long modulusLength = 0;
@@ -717,7 +720,7 @@ static int cca_rsa_verify(int type, const unsigned char *m, unsigned int m_len,
 
        if (type == NID_sha1 || type == NID_md5)
                {
-               memset(hashBuffer, 0, keyLength+1);
+               OPENSSL_cleanse(hashBuffer, keyLength+1);
                OPENSSL_free(hashBuffer);
                }
 
@@ -840,7 +843,7 @@ static int cca_rsa_sign(int type, const unsigned char *m, unsigned int m_len,
 
        if (type == NID_sha1 || type == NID_md5)
                {
-               memset(hashBuffer, 0, keyLength+1);
+               OPENSSL_cleanse(hashBuffer, keyLength+1);
                OPENSSL_free(hashBuffer);
                }
 
@@ -921,7 +924,7 @@ static int cca_get_random_bytes(unsigned char* buf, int num)
        unsigned char form[] = "RANDOM  ";
        unsigned char rand_buf[8];
 
-       while(num >= sizeof(rand_buf))
+       while(num >= (int)sizeof(rand_buf))
                {
                randomNumberGenerate(&ret_code, &reason_code, &exit_data_length,
                        exit_data, form, rand_buf);