static int dsa_capi_idx = -1;
static int capi_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f)(void))
-{
+ {
int ret = 1;
CAPI_CTX *ctx;
BIO *out;
BIO_free(out);
return ret;
-}
+ }
static RSA_METHOD capi_rsa_method =
{
static int capi_destroy(ENGINE *e)
{
-
ERR_unload_CAPI_strings();
return 1;
}
return -1;
}
/* Convert the signature type to a CryptoAPI algorithm ID */
- switch(dtype) {
+ switch(dtype)
+ {
case NID_sha1:
alg = CALG_SHA1;
break;
/* Create the hash object */
- if(!CryptCreateHash(capi_key->hprov, alg, 0, 0, &hash)) {
+ if(!CryptCreateHash(capi_key->hprov, alg, 0, 0, &hash))
+ {
CAPIerr(CAPI_F_CAPI_RSA_SIGN, CAPI_R_CANT_CREATE_HASH_OBJECT);
capi_addlasterror();
return -1;
- }
+ }
/* Set the hash value to the value passed */
- if(!CryptSetHashParam(hash, HP_HASHVAL, (unsigned char *)m, 0)) {
+ if(!CryptSetHashParam(hash, HP_HASHVAL, (unsigned char *)m, 0))
+ {
CAPIerr(CAPI_F_CAPI_RSA_SIGN, CAPI_R_CANT_SET_HASH_VALUE);
capi_addlasterror();
goto err;
- }
+ }
/* Finally sign it */
slen = RSA_size(rsa);
- if(!CryptSignHash(hash, capi_key->keyspec, NULL, 0, sigret, &slen)) {
+ if(!CryptSignHash(hash, capi_key->keyspec, NULL, 0, sigret, &slen))
+ {
CAPIerr(CAPI_F_CAPI_RSA_SIGN, CAPI_R_ERROR_SIGNING_HASH);
capi_addlasterror();
goto err;
- } else {
+ }
+ else
+ {
ret = 1;
/* Inplace byte reversal of signature */
- for(i = 0; i < slen / 2; i++) {
+ for(i = 0; i < slen / 2; i++)
+ {
unsigned char c;
c = sigret[i];
sigret[i] = sigret[slen - i - 1];
sigret[slen - i - 1] = c;
- }
+ }
*siglen = slen;
- }
+ }
/* Now cleanup */
CryptDestroyHash(hash);
return ret;
-}
+ }
int capi_rsa_priv_dec(int flen, const unsigned char *from,
unsigned char *to, RSA *rsa, int padding)
-{
+ {
int i;
unsigned char *tmpbuf;
CAPI_KEY *capi_key;
OPENSSL_free(tmpbuf);
return flen;
-}
+ }
static int capi_rsa_free(RSA *rsa)
{
}
/* Create the hash object */
- if(!CryptCreateHash(capi_key->hprov, CALG_SHA1, 0, 0, &hash)) {
+ if(!CryptCreateHash(capi_key->hprov, CALG_SHA1, 0, 0, &hash))
+ {
CAPIerr(CAPI_F_CAPI_DSA_DO_SIGN, CAPI_R_CANT_CREATE_HASH_OBJECT);
capi_addlasterror();
return NULL;
- }
+ }
/* Set the hash value to the value passed */
- if(!CryptSetHashParam(hash, HP_HASHVAL, (unsigned char *)digest, 0)) {
+ if(!CryptSetHashParam(hash, HP_HASHVAL, (unsigned char *)digest, 0))
+ {
CAPIerr(CAPI_F_CAPI_DSA_DO_SIGN, CAPI_R_CANT_SET_HASH_VALUE);
capi_addlasterror();
goto err;
- }
+ }
/* Finally sign it */
for (idx = 0;;idx++)
{
- clen = buflen;
- cname[0] = 0;
-
- if (idx == 0)
- flags = CRYPT_FIRST;
- else
- flags = 0;
- if(!CryptGetProvParam(hprov, PP_ENUMCONTAINERS, cname, &clen, flags))
- {
- err = GetLastError();
- if (err == ERROR_NO_MORE_ITEMS)
- goto done;
- CAPIerr(CAPI_F_CAPI_LIST_CONTAINERS, CAPI_R_ENUMCONTAINERS_ERROR);
- capi_adderror(err);
- goto err;
- }
- CAPI_trace(ctx, "Container name %s, len=%d, index=%d, flags=%d\n", cname, clen, idx, flags);
- if (!cname[0] && (clen == buflen))
- {
- CAPI_trace(ctx, "Enumerate bug: using workaround\n");
+ clen = buflen;
+ cname[0] = 0;
+
+ if (idx == 0)
+ flags = CRYPT_FIRST;
+ else
+ flags = 0;
+ if(!CryptGetProvParam(hprov, PP_ENUMCONTAINERS, cname, &clen, flags))
+ {
+ err = GetLastError();
+ if (err == ERROR_NO_MORE_ITEMS)
goto done;
- }
- BIO_printf(out, "%d. %s\n", idx, cname);
+ CAPIerr(CAPI_F_CAPI_LIST_CONTAINERS, CAPI_R_ENUMCONTAINERS_ERROR);
+ capi_adderror(err);
+ goto err;
+ }
+ CAPI_trace(ctx, "Container name %s, len=%d, index=%d, flags=%d\n", cname, clen, idx, flags);
+ if (!cname[0] && (clen == buflen))
+ {
+ CAPI_trace(ctx, "Enumerate bug: using workaround\n");
+ goto done;
+ }
+ BIO_printf(out, "%d. %s\n", idx, cname);
}
err:
switch(ctx->lookup_method)
{
case CAPI_LU_SUBSTR:
- return CertFindCertificateInStore(hstore, X509_ASN_ENCODING, 0,
- CERT_FIND_SUBJECT_STR_A, id, NULL);
+ return CertFindCertificateInStore(hstore,
+ X509_ASN_ENCODING, 0,
+ CERT_FIND_SUBJECT_STR_A, id, NULL);
case CAPI_LU_FNAME:
for(;;)
{
CAPI_KEY *key;
key = OPENSSL_malloc(sizeof(CAPI_KEY));
CAPI_trace(ctx, "capi_get_key, contname=%s, provname=%s, type=%d\n",
- contname, provname, ptype);
+ contname, provname, ptype);
if (!CryptAcquireContext(&key->hprov, contname, provname, ptype, 0))
{
CAPIerr(CAPI_F_CAPI_GET_KEY, CAPI_R_CRYPTACQUIRECONTEXT_ERROR);
if (!provname || !contname)
return 0;
- key = capi_get_key(ctx, contname, provname, pinfo->dwProvType, pinfo->dwKeySpec);
+ key = capi_get_key(ctx, contname, provname,
+ pinfo->dwProvType, pinfo->dwKeySpec);
err:
if (pinfo)
break;
case CAPI_LU_CONTNAME:
- key = capi_get_key(ctx, id, ctx->cspname, ctx->csptype, ctx->keytype);
+ key = capi_get_key(ctx, id, ctx->cspname, ctx->csptype,
+ ctx->keytype);
break;
}
if (check)
{
HCRYPTPROV hprov;
- if (!CryptAcquireContext(&hprov, NULL, pname, type, CRYPT_VERIFYCONTEXT))
+ if (!CryptAcquireContext(&hprov, NULL, pname, type,
+ CRYPT_VERIFYCONTEXT))
{
CAPIerr(CAPI_F_CAPI_CTX_SET_PROVNAME, CAPI_R_CRYPTACQUIRECONTEXT_ERROR);
capi_addlasterror();