diff options
author | Stef Walter <stef@memberwebs.com> | 2008-12-09 01:51:54 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2008-12-09 01:51:54 +0000 |
commit | a71df0e849b4e286f29ae6e26973961d3412cd83 (patch) | |
tree | 71fff8c8e760561287ddae96ffdfb051e5f6a220 /ckcapi.c | |
parent | f84cec479d41fb143487af7e78a6b3056f6b8823 (diff) |
Complete the certificate support so most of the tests clear.
Diffstat (limited to 'ckcapi.c')
-rw-r--r-- | ckcapi.c | 48 |
1 files changed, 48 insertions, 0 deletions
@@ -290,6 +290,54 @@ ckcapi_return_reversed_data(CK_ATTRIBUTE_PTR attr, CK_VOID_PTR data, CK_ULONG le return CKR_OK; } +static void +print_zero_decimal(CK_BYTE_PTR buffer, CK_ULONG length, WORD value) +{ + int i; + for(i = (int)length - 1; i >= 0; --i) + { + BYTE digit = value % 10; + buffer[i] = '0' + digit; + value /= 10; + } +} + +CK_RV +ckcapi_return_filetime(CK_ATTRIBUTE_PTR attr, FILETIME *ftime) +{ + SYSTEMTIME stime; + CK_DATE* date; + + ASSERT(attr); + ASSERT(ftime); + + if(!attr->pValue) + { + attr->ulValueLen = sizeof(CK_DATE); + return CKR_OK; + } + + if(attr->ulValueLen < sizeof(CK_DATE)) + { + attr->ulValueLen = sizeof(CK_DATE); + return CKR_BUFFER_TOO_SMALL; + } + + if(!FileTimeToSystemTime(ftime, &stime)) + { + DBG(("An invalid FILETIME was encountered")); + return CKR_GENERAL_ERROR; + } + + date = (CK_DATE*)attr->pValue; + attr->ulValueLen = sizeof(CK_DATE); + print_zero_decimal(date->year, sizeof(date->year), stime.wYear); + print_zero_decimal(date->month, sizeof(date->month), stime.wMonth); + print_zero_decimal(date->day, sizeof(date->day), stime.wDay); + + return CKR_OK; +} + /* ---------------------------------------------------------------- */ static CK_RV |