1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| CRYPT_DEVICE cryptDevice;
CRYPT_QUERY_INFO cryptQueryInfo;
int status = 0;
char label[CRYPT_MAX_TEXTSIZE];
int labelLength;
status = cryptDeviceOpen(&cryptDevice, CRYPT_UNUSED, CRYPT_DEVICE_HARDWARE, "[Autodetect]");
if (cryptStatusError(status))
{
printf("Can't open device\n");
goto exit;
}
else
{
status = cryptGetAttributeString(cryptDevice, CRYPT_DEVINFO_LABEL, label, &labelLength);
if (cryptStatusError(status))
{
printf("Can't get device's informations.\n");
cryptDeviceClose(cryptDevice);
goto exit;
}
else
{
label[labelLength] = '\0';
printf("device name : %s\n", label);
//cryptDeviceClose(cryptDevice);
}
}
status = cryptDeviceQueryCapability(cryptDevice, CRYPT_ALGO_RSA , &cryptQueryInfo);
if (cryptStatusError(status))
{
printf("can't get device capability info\n");
goto exit;
}
else
{
printf("RSA algo available\n");
printf("Algo size %d\n", cryptQueryInfo.keySize);
printf("Algo max key size %d\n", cryptQueryInfo.maxKeySize);
}
exit:
return status; |
Partager