Templatize util/domd
[openssl.git] / engines / e_capi.c
index a38592b5f65194bf0ab76b7e75fddddabc78a24e..d3c9b8b163bfcc00497d04ef80d8425b3e5196be 100644 (file)
@@ -1,4 +1,3 @@
-/* engines/e_capi.c */
 /*
  * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
  * project.
@@ -361,7 +360,7 @@ static int capi_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void))
 
     case CAPI_CMD_STORE_NAME:
         OPENSSL_free(ctx->storename);
-        ctx->storename = BUF_strdup(p);
+        ctx->storename = OPENSSL_strdup(p);
         CAPI_trace(ctx, "Setting store name to %s\n", p);
         break;
 
@@ -382,7 +381,7 @@ static int capi_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void))
         break;
 
     case CAPI_CMD_DEBUG_FILE:
-        ctx->debug_file = BUF_strdup(p);
+        ctx->debug_file = OPENSSL_strdup(p);
         CAPI_trace(ctx, "Setting debug file to %s\n", ctx->debug_file);
         break;
 
@@ -436,7 +435,7 @@ static RSA_METHOD capi_rsa_method = {
     0,                          /* bn_mod_exp */
     0,                          /* init */
     capi_rsa_free,              /* finish */
-    RSA_FLAG_SIGN_VER,          /* flags */
+    0,                          /* flags */
     NULL,                       /* app_data */
     capi_rsa_sign,              /* rsa_sign */
     0                           /* rsa_verify */
@@ -487,7 +486,7 @@ static int capi_init(ENGINE *e)
     }
 
     ctx = capi_ctx_new();
-    if (!ctx)
+    if (ctx == NULL)
         goto memerr;
 
     ENGINE_set_ex_data(e, capi_idx, ctx);
@@ -584,7 +583,7 @@ IMPLEMENT_DYNAMIC_CHECK_FN()
 static ENGINE *engine_capi(void)
 {
     ENGINE *ret = ENGINE_new();
-    if (!ret)
+    if (ret == NULL)
         return NULL;
     if (!bind_capi(ret)) {
         ENGINE_free(ret);
@@ -643,7 +642,7 @@ static EVP_PKEY *capi_get_pkey(ENGINE *eng, CAPI_KEY * key)
 
     pubkey = OPENSSL_malloc(len);
 
-    if (!pubkey)
+    if (pubkey == NULL)
         goto memerr;
 
     if (!CryptExportKey(key->key, 0, PUBLICKEYBLOB, 0, pubkey, &len)) {
@@ -678,7 +677,7 @@ static EVP_PKEY *capi_get_pkey(ENGINE *eng, CAPI_KEY * key)
         rkey->e = BN_new();
         rkey->n = BN_new();
 
-        if (!rkey->e || !rkey->n)
+        if (rkey->e == NULL || rkey->n == NULL)
             goto memerr;
 
         if (!BN_set_word(rkey->e, rp->pubexp))
@@ -718,7 +717,8 @@ static EVP_PKEY *capi_get_pkey(ENGINE *eng, CAPI_KEY * key)
         dkey->q = BN_new();
         dkey->g = BN_new();
         dkey->pub_key = BN_new();
-        if (!dkey->p || !dkey->q || !dkey->g || !dkey->pub_key)
+        if (dkey->p == NULL || dkey->q == NULL || dkey->g == NULL
+                || dkey->pub_key == NULL)
             goto memerr;
         if (!lend_tobn(dkey->p, btmp, dsa_plen))
             goto memerr;
@@ -1006,11 +1006,11 @@ static DSA_SIG *capi_dsa_do_sign(const unsigned char *digest, int dlen,
         goto err;
     } else {
         ret = DSA_SIG_new();
-        if (!ret)
+        if (ret == NULL)
             goto err;
         ret->r = BN_new();
         ret->s = BN_new();
-        if (!ret->r || !ret->s)
+        if (ret->r == NULL || ret->s == NULL)
             goto err;
         if (!lend_tobn(ret->r, csigbuf, 20)
             || !lend_tobn(ret->s, csigbuf + 20, 20)) {
@@ -1087,7 +1087,7 @@ static char *wide_to_asc(LPCWSTR wstr)
         return NULL;
     }
     str = OPENSSL_malloc(sz);
-    if (!str) {
+    if (str == NULL) {
         CAPIerr(CAPI_F_WIDE_TO_ASC, ERR_R_MALLOC_FAILURE);
         return NULL;
     }
@@ -1201,7 +1201,7 @@ static int capi_list_containers(CAPI_CTX * ctx, BIO *out)
     if (buflen == 0)
         buflen = 1024;
     cname = OPENSSL_malloc(buflen);
-    if (!cname) {
+    if (cname == NULL) {
         CAPIerr(CAPI_F_CAPI_LIST_CONTAINERS, ERR_R_MALLOC_FAILURE);
         goto err;
     }
@@ -1251,7 +1251,7 @@ static CRYPT_KEY_PROV_INFO *capi_get_prov_info(CAPI_CTX * ctx, PCCERT_CONTEXT ce
         (cert, CERT_KEY_PROV_INFO_PROP_ID, NULL, &len))
         return NULL;
     pinfo = OPENSSL_malloc(len);
-    if (!pinfo) {
+    if (pinfo == NULL) {
         CAPIerr(CAPI_F_CAPI_GET_PROV_INFO, ERR_R_MALLOC_FAILURE);
         return NULL;
     }
@@ -1581,7 +1581,7 @@ static CAPI_CTX *capi_ctx_new(void)
 {
     CAPI_CTX *ctx = OPENSSL_zalloc(sizeof(*ctx));
 
-    if (!ctx) {
+    if (ctx == NULL) {
         CAPIerr(CAPI_F_CAPI_CTX_NEW, ERR_R_MALLOC_FAILURE);
         return NULL;
     }
@@ -1634,7 +1634,7 @@ static int capi_ctx_set_provname(CAPI_CTX * ctx, LPSTR pname, DWORD type,
         CryptReleaseContext(hprov, 0);
     }
     OPENSSL_free(ctx->cspname);
-    ctx->cspname = BUF_strdup(pname);
+    ctx->cspname = OPENSSL_strdup(pname);
     ctx->csptype = type;
     return 1;
 }