Overview
Comment: | Updated to support unpadding |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
ebeffd66b45d8ab6a5423d0d79713db0 |
User & Date: | rkeene on 2010-05-17 22:22:04 |
Other Links: | manifest | tags |
Context
2010-05-17
| ||
23:11 | Updated debugging output check-in: 824ac1bc2e user: rkeene tags: trunk | |
22:22 | Updated to support unpadding check-in: ebeffd66b4 user: rkeene tags: trunk | |
21:50 | Corrected issue with sign/decrypt buffer sizes check-in: 9aa715ce7f user: rkeene tags: trunk | |
Changes
Modified cackey.c from [6f8796b70d] to [b1f39a9840].
︙ | |||
1835 1836 1837 1838 1839 1840 1841 | 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 | - + + - + - + | * RETURN VALUE * ... * * NOTES * ... * */ |
︙ | |||
1889 1890 1891 1892 1893 1894 1895 | 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 | + - - - - + + + + - - + + - - - + + + - + - - - - - + + + + + - - - + + + + + + + + + + + - - | /* Determine identity Key size */ if (identity->pcsc_identity->keysize < 0) { identity->pcsc_identity->keysize = x509_to_keysize(identity->pcsc_identity->certificate, identity->pcsc_identity->certificate_len); } /* Pad message to key size */ if (padInput) { |
︙ | |||
1997 1998 1999 2000 2001 2002 2003 | 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + | CACKEY_DEBUG_PRINTF("Outbuflen exceeds maximum value, returning in failure. (max = %li, outbuflen = %lu)", (long) _POSIX_SSIZE_MAX, (unsigned long) outbuflen); return(-1); } # endif #endif /* Unpad reply */ if (unpadOutput) { if (retval < 2) { CACKEY_DEBUG_PRINTF("Reply is too small, we are not able to unpad -- passing back and hoping for the best!"); return(retval); } blocktype = outbuf[0]; unpadoffset = 0; switch (blocktype) { case 0x00: /* Padding Scheme 1, the first non-zero byte is the start of data */ for (unpadoffset = 1; unpadoffset < retval; unpadoffset++) { if (outbuf[unpadoffset] != 0x00) { break; } } break; case 0x01: /* Padding Scheme 2, pad bytes are 0xFF followed by 0x00 */ for (unpadoffset = 1; unpadoffset < retval; unpadoffset++) { if (outbuf[unpadoffset] != 0xFF) { if (outbuf[unpadoffset] == 0x00) { unpadoffset++; break; } else { CACKEY_DEBUG_PRINTF("Invalid padding data found, returning in failure, should have been 0x00 found 0x%02x", (unsigned int) outbuf[unpadoffset]); return(-1); } } else { CACKEY_DEBUG_PRINTF("Invalid padding data found, returning in failure, should have been 0xFF found 0x%02x", (unsigned int) outbuf[unpadoffset]); return(-1); } } break; case 0x02: /* Padding Scheme 3, pad bytes are non-zero first non-zero byte found is the pad byte */ for (unpadoffset = 1; unpadoffset < retval; unpadoffset++) { if (outbuf[unpadoffset] == 0x00) { continue; } if (sepByte == -1) { sepByte = outbuf[unpadoffset]; continue; } if (outbuf[unpadoffset] == sepByte) { unpadoffset++; break; } } break; } if (unpadoffset > retval) { CACKEY_DEBUG_PRINTF("Offset greater than reply size, aborting. (unpadoffset = %lu, retval = %lu)", (unsigned long) unpadoffset, (unsigned long) retval); return(-1); } CACKEY_DEBUG_PRINTBUF("Padded:", outbuf, retval); retval -= unpadoffset; memmove(outbuf + unpadoffset, outbuf, retval); CACKEY_DEBUG_PRINTBUF("Unpadded:", outbuf, retval); } |
︙ | |||
4470 4471 4472 4473 4474 4475 4476 | 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 | - + | return(CKR_OPERATION_NOT_INITIALIZED); } switch (cackey_sessions[hSession].decrypt_mechanism) { case CKM_RSA_PKCS: /* Ask card to decrypt */ |
︙ | |||
4906 4907 4908 4909 4910 4911 4912 | 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 | - + | return(CKR_OPERATION_NOT_INITIALIZED); } switch (cackey_sessions[hSession].sign_mechanism) { case CKM_RSA_PKCS: /* Ask card to sign */ CACKEY_DEBUG_PRINTF("Asking to decrypt from identity %p in session %lu", cackey_sessions[hSession].sign_identity, (unsigned long) hSession); |
︙ |