Changeset 778 in openpam


Ignore:
Timestamp:
Mar 9, 2014, 2:10:06 PM (7 years ago)
Author:
Dag-Erling Smørgrav
Message:

Add test vectors which encode to the complete alphabet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/t/t_rfc4648.c

    r775 r778  
    7070
    7171/* roundtrip encoding tests */
     72#define T_ENCDEC_N(N, p, e)                                             \
     73        T_ENCODE_N(N, p, e), T_DECODE_N(N, e, p)
    7274#define T_ENCDEC(p, b32, b64)                                           \
    73         T_ENCODE(p, b32, b64), T_DECODE(p, b32, b64)
     75        T_ENCDEC_N(32, p, b32), T_ENCDEC_N(64, p, b64)
    7476
    7577/* decoding failure */
     
    101103        T_LONG_OUTPUT_DEC(64, "AAAA")
    102104
     105static const char b64alphabet[] =
     106    "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
     107    "abcdefghijklmnopqrstuvwxyz"
     108    "0123456789+/";
     109static const char b64complete[] = {
     110        0x00, 0x10, 0x83, 0x10, 0x51, 0x87,
     111        0x20, 0x92, 0x8b, 0x30, 0xd3, 0x8f,
     112        0x41, 0x14, 0x93, 0x51, 0x55, 0x97,
     113        0x61, 0x96, 0x9b, 0x71, 0xd7, 0x9f,
     114        0x82, 0x18, 0xa3, 0x92, 0x59, 0xa7,
     115        0xa2, 0x9a, 0xab, 0xb2, 0xdb, 0xaf,
     116        0xc3, 0x1c, 0xb3, 0xd3, 0x5d, 0xb7,
     117        0xe3, 0x9e, 0xbb, 0xf3, 0xdf, 0xbf,
     118        0x00
     119};
     120
     121static const char b32alphabet[] =
     122    "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
     123static const char b32complete[] = {
     124        0x00, 0x44, 0x32, 0x14, 0xc7,
     125        0x42, 0x54, 0xb6, 0x35, 0xcf,
     126        0x84, 0x65, 0x3a, 0x56, 0xd7,
     127        0xc6, 0x75, 0xbe, 0x77, 0xdf,
     128        0x00
     129};
     130
    103131static struct t_case t_cases[] = {
     132        /* complete alphabet */
     133        T_ENCDEC_N(32, b32complete, b32alphabet),
     134        T_ENCDEC_N(64, b64complete, b64alphabet),
     135
    104136        /* test vectors from RFC 4648 */
    105137        /*       plain          base32                  base64 */
Note: See TracChangeset for help on using the changeset viewer.