equal
deleted
inserted
replaced
500 bHasNoPrivateKey = TRUE; |
500 bHasNoPrivateKey = TRUE; |
501 } |
501 } |
502 else |
502 else |
503 { |
503 { |
504 if ((dwKeySpec & CERT_NCRYPT_KEY_SPEC) == CERT_NCRYPT_KEY_SPEC) { |
504 if ((dwKeySpec & CERT_NCRYPT_KEY_SPEC) == CERT_NCRYPT_KEY_SPEC) { |
505 PP("CNG %I64d", hCryptProv); |
505 PP("CNG %I64d", (__int64)hCryptProv); |
506 } else { |
506 } else { |
507 // Private key is available |
507 // Private key is available |
508 BOOL bGetUserKey = ::CryptGetUserKey(hCryptProv, dwKeySpec, &hUserKey); //deprecated |
508 BOOL bGetUserKey = ::CryptGetUserKey(hCryptProv, dwKeySpec, &hUserKey); //deprecated |
509 |
509 |
510 // Skip certificate if cannot find private key |
510 // Skip certificate if cannot find private key |
515 } |
515 } |
516 |
516 |
517 // Set cipher mode to ECB |
517 // Set cipher mode to ECB |
518 DWORD dwCipherMode = CRYPT_MODE_ECB; |
518 DWORD dwCipherMode = CRYPT_MODE_ECB; |
519 ::CryptSetKeyParam(hUserKey, KP_MODE, (BYTE*)&dwCipherMode, NULL); //deprecated |
519 ::CryptSetKeyParam(hUserKey, KP_MODE, (BYTE*)&dwCipherMode, NULL); //deprecated |
520 PP("CAPI %I64d %I64d", hCryptProv, hUserKey); |
520 PP("CAPI %I64d %I64d", (__int64)hCryptProv, (__int64)hUserKey); |
521 } |
521 } |
522 // If the private key is present in smart card, we may not be able to |
522 // If the private key is present in smart card, we may not be able to |
523 // determine the key length by using the private key handle. However, |
523 // determine the key length by using the private key handle. However, |
524 // since public/private key pairs must have the same length, we could |
524 // since public/private key pairs must have the same length, we could |
525 // determine the key length of the private key by using the public key |
525 // determine the key length of the private key by using the public key |
861 hk = (NCRYPT_KEY_HANDLE)hCryptProv; |
861 hk = (NCRYPT_KEY_HANDLE)hCryptProv; |
862 } else { |
862 } else { |
863 SS_CHECK(::NCryptTranslateHandle( |
863 SS_CHECK(::NCryptTranslateHandle( |
864 NULL, |
864 NULL, |
865 &hk, |
865 &hk, |
866 hCryptProv, |
866 (HCRYPTPROV)hCryptProv, |
867 hCryptKey, |
867 (HCRYPTKEY)hCryptKey, |
868 NULL, |
868 NULL, |
869 0)); |
869 0)); |
870 } |
870 } |
871 |
871 |
872 // Copy hash from Java to native buffer |
872 // Copy hash from Java to native buffer |
1085 hk = (NCRYPT_KEY_HANDLE)hCryptProv; |
1085 hk = (NCRYPT_KEY_HANDLE)hCryptProv; |
1086 } else { |
1086 } else { |
1087 SS_CHECK(::NCryptTranslateHandle( |
1087 SS_CHECK(::NCryptTranslateHandle( |
1088 NULL, |
1088 NULL, |
1089 &hk, |
1089 &hk, |
1090 hCryptProv, |
1090 (HCRYPTPROV)hCryptProv, |
1091 hCryptKey, |
1091 (HCRYPTKEY)hCryptKey, |
1092 NULL, |
1092 NULL, |
1093 0)); |
1093 0)); |
1094 } |
1094 } |
1095 |
1095 |
1096 // Copy hash and signedHash from Java to native buffer |
1096 // Copy hash and signedHash from Java to native buffer |
1918 { |
1918 { |
1919 |
1919 |
1920 // Determine the size of the blob |
1920 // Determine the size of the blob |
1921 if (hCryptKey == 0) { |
1921 if (hCryptKey == 0) { |
1922 SS_CHECK(::NCryptExportKey( |
1922 SS_CHECK(::NCryptExportKey( |
1923 hCryptProv, NULL, BCRYPT_ECCPUBLIC_BLOB, |
1923 (NCRYPT_KEY_HANDLE)hCryptProv, NULL, BCRYPT_ECCPUBLIC_BLOB, |
1924 NULL, NULL, 0, &dwBlobLen, NCRYPT_SILENT_FLAG)); |
1924 NULL, NULL, 0, &dwBlobLen, NCRYPT_SILENT_FLAG)); |
1925 } else { |
1925 } else { |
1926 if (! ::CryptExportKey((HCRYPTKEY) hCryptKey, 0, PUBLICKEYBLOB, 0, NULL, //deprecated |
1926 if (! ::CryptExportKey((HCRYPTKEY) hCryptKey, 0, PUBLICKEYBLOB, 0, NULL, //deprecated |
1927 &dwBlobLen)) { |
1927 &dwBlobLen)) { |
1928 |
1928 |
1937 } |
1937 } |
1938 |
1938 |
1939 // Generate key blob |
1939 // Generate key blob |
1940 if (hCryptKey == 0) { |
1940 if (hCryptKey == 0) { |
1941 SS_CHECK(::NCryptExportKey( |
1941 SS_CHECK(::NCryptExportKey( |
1942 hCryptProv, NULL, BCRYPT_ECCPUBLIC_BLOB, |
1942 (NCRYPT_KEY_HANDLE)hCryptProv, NULL, BCRYPT_ECCPUBLIC_BLOB, |
1943 NULL, pbKeyBlob, dwBlobLen, &dwBlobLen, NCRYPT_SILENT_FLAG)); |
1943 NULL, pbKeyBlob, dwBlobLen, &dwBlobLen, NCRYPT_SILENT_FLAG)); |
1944 } else { |
1944 } else { |
1945 if (! ::CryptExportKey((HCRYPTKEY) hCryptKey, 0, PUBLICKEYBLOB, 0, //deprecated |
1945 if (! ::CryptExportKey((HCRYPTKEY) hCryptKey, 0, PUBLICKEYBLOB, 0, //deprecated |
1946 pbKeyBlob, &dwBlobLen)) { |
1946 pbKeyBlob, &dwBlobLen)) { |
1947 |
1947 |