prevent compilation errors and warnings
[oweals/openssl.git] / crypto / engine / eng_cryptodev.c
index bc4b689230aed1df444aa75ac9447222f2308dc3..52f4ca39019851b33d58e6201f0438d559aeb223 100644 (file)
@@ -130,7 +130,7 @@ static int cryptodev_mod_exp_dh(const DH *dh, BIGNUM *r, const BIGNUM *a,
 static int cryptodev_dh_compute_key(unsigned char *key,
     const BIGNUM *pub_key, DH *dh);
 static int cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p,
-    void (*f)());
+    void (*f)(void));
 void ENGINE_load_cryptodev(void);
 
 static const ENGINE_CMD_DEFN cryptodev_defns[] = {
@@ -1017,10 +1017,18 @@ cryptodev_bn_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
                goto err;
        kop.crk_iparams = 3;
 
-       if (cryptodev_asym(&kop, BN_num_bytes(m), r, 0, NULL) == -1) {
+       if (cryptodev_asym(&kop, BN_num_bytes(m), r, 0, NULL)) {
                const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
+               printf("OCF asym process failed, Running in software\n");
+               ret = meth->bn_mod_exp(r, a, p, m, ctx, in_mont);
+
+       } else if (ECANCELED == kop.crk_status) {
+               const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
+               printf("OCF hardware operation cancelled. Running in Software\n");
                ret = meth->bn_mod_exp(r, a, p, m, ctx, in_mont);
        }
+       /* else cryptodev operation worked ok ==> ret = 1*/
+
 err:
        zapparams(&kop);
        return (ret);
@@ -1064,10 +1072,18 @@ cryptodev_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
                goto err;
        kop.crk_iparams = 6;
 
-       if (cryptodev_asym(&kop, BN_num_bytes(rsa->n), r0, 0, NULL) == -1) {
+       if (cryptodev_asym(&kop, BN_num_bytes(rsa->n), r0, 0, NULL)) {
                const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
+               printf("OCF asym process failed, running in Software\n");
+               ret = (*meth->rsa_mod_exp)(r0, I, rsa, ctx);
+
+       } else if (ECANCELED == kop.crk_status) {
+               const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
+               printf("OCF hardware operation cancelled. Running in Software\n");
                ret = (*meth->rsa_mod_exp)(r0, I, rsa, ctx);
        }
+       /* else cryptodev operation worked ok ==> ret = 1*/
+
 err:
        zapparams(&kop);
        return (ret);
@@ -1203,7 +1219,8 @@ cryptodev_dsa_verify(const unsigned char *dgst, int dlen,
        kop.crk_iparams = 7;
 
        if (cryptodev_asym(&kop, 0, NULL, 0, NULL) == 0) {
-               dsaret = kop.crk_status;
+/*OCF success value is 0, if not zero, change dsaret to fail*/
+               if(0 != kop.crk_status) dsaret  = 0;
        } else {
                const DSA_METHOD *meth = DSA_OpenSSL();
 
@@ -1294,7 +1311,7 @@ static DH_METHOD cryptodev_dh = {
  * but I expect we'll want some options soon.
  */
 static int
-cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)())
+cryptodev_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
 {
 #ifdef HAVE_SYSLOG_R
        struct syslog_data sd = SYSLOG_DATA_INIT;