hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

pkcs1_test.ha (16769B)


      1 // SPDX-License-Identifier: MPL-2.0
      2 // (c) Hare authors <https://harelang.org>
      3 
      4 use bytes;
      5 use crypto::sha1;
      6 use crypto::sha256;
      7 use crypto::sha512;
      8 use hash;
      9 use io;
     10 
     11 const msg: [_]u8 = [
     12 	0x53, 0x53, 0x48, 0x53, 0x49, 0x47, 0x00, 0x00, 0x00, 0x03, 0x6a, 0x6f,
     13 	0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x73, 0x68, 0x61,
     14 	0x35, 0x31, 0x32, 0x00, 0x00, 0x00, 0x40, 0xce, 0x25, 0x8d, 0xf2, 0x3a,
     15 	0x14, 0xf2, 0x80, 0xeb, 0xea, 0x9b, 0xd4, 0xd7, 0xb8, 0x94, 0xce, 0x23,
     16 	0x98, 0xa8, 0x27, 0x30, 0x42, 0x61, 0x6a, 0xd2, 0x15, 0x59, 0x97, 0xc2,
     17 	0xb4, 0x79, 0x8b, 0x16, 0xdc, 0x49, 0xb5, 0x26, 0x51, 0x77, 0xe3, 0x27,
     18 	0x5c, 0xdf, 0xc0, 0xa5, 0x46, 0x97, 0xdb, 0x7b, 0x2c, 0x3b, 0x9b, 0x97,
     19 	0x3e, 0xc9, 0xca, 0xea, 0x9a, 0xcd, 0xbd, 0x2c, 0xaa, 0xcc, 0x77,
     20 ];
     21 
     22 const sig1: [_] u8 = [
     23 	0x3a, 0x29, 0x89, 0x83, 0xf5, 0xb6, 0x25, 0x0c, 0x00, 0xd4, 0x44, 0x4a,
     24 	0x16, 0xa9, 0xcf, 0xb6, 0x14, 0x3d, 0xc1, 0xa9, 0x45, 0x24, 0xb1, 0x54,
     25 	0x53, 0x2b, 0x59, 0x81, 0xf8, 0x7c, 0xdb, 0x4c, 0x16, 0xd1, 0x0e, 0x68,
     26 	0xb8, 0x1a, 0x48, 0x02, 0x3d, 0x34, 0x08, 0x14, 0xb7, 0xc1, 0x90, 0x1f,
     27 	0x4d, 0x7f, 0xbc, 0xa1, 0xef, 0x8c, 0xf0, 0x71, 0x24, 0x11, 0x27, 0xa7,
     28 	0x1c, 0xc9, 0x44, 0x11, 0x65, 0x1e, 0xca, 0xa0, 0x4b, 0xb5, 0x27, 0x67,
     29 	0xe3, 0x80, 0x4d, 0x79, 0xbf, 0x28, 0xb9, 0x85, 0xe8, 0x27, 0xad, 0x7d,
     30 	0xca, 0x2e, 0x0d, 0xb2, 0xe6, 0x42, 0x29, 0x37, 0x8b, 0xb2, 0xc3, 0x0c,
     31 	0x49, 0x9f, 0x78, 0x2c, 0x03, 0xe4, 0x2e, 0x83, 0x79, 0xb0, 0x6c, 0x09,
     32 	0xf4, 0x3c, 0xc7, 0x14, 0xfa, 0x73, 0x41, 0x28, 0x39, 0x1f, 0x8a, 0x23,
     33 	0x7b, 0x71, 0x5d, 0x15, 0x23, 0x69, 0x95, 0x1c, 0x8d, 0x50, 0x6c, 0x4e,
     34 	0x6e, 0x7d, 0xab, 0xcf, 0xab, 0xbd, 0xa2, 0xf1, 0x18, 0x2d, 0xb3, 0x70,
     35 	0x5d, 0x62, 0x45, 0xad, 0xa9, 0x1b, 0x40, 0x1f, 0xe8, 0xe1, 0x25, 0x19,
     36 	0x78, 0xfd, 0x73, 0x49, 0x45, 0x09, 0x21, 0x5c, 0x25, 0xff, 0x86, 0x1d,
     37 	0x6c, 0x63, 0xc6, 0xc1, 0xc0, 0x56, 0xe9, 0x84, 0x6d, 0x15, 0xc6, 0xcf,
     38 	0xeb, 0x33, 0xc5, 0x80, 0xda, 0x34, 0x30, 0x04, 0x92, 0x91, 0x04, 0xeb,
     39 	0x8f, 0xcb, 0x42, 0xd4, 0x41, 0x9a, 0x03, 0x86, 0x35, 0xed, 0x78, 0xa6,
     40 	0x1e, 0x95, 0x5f, 0x5e, 0x9e, 0xc0, 0x23, 0x3a, 0xd1, 0x72, 0xc3, 0x9a,
     41 	0x16, 0x6b, 0xa5, 0xc3, 0x90, 0x40, 0x1b, 0x56, 0xe3, 0xc2, 0xd5, 0x66,
     42 	0xb0, 0x86, 0xfe, 0x54, 0xb7, 0xa4, 0x51, 0xba, 0x41, 0xae, 0xb0, 0xd5,
     43 	0xad, 0x76, 0x13, 0x7b, 0xa6, 0x4d, 0x3e, 0x77, 0x59, 0x27, 0xcd, 0x31,
     44 	0x4a, 0xfb, 0xbd, 0x79, 0x9a, 0xc6, 0x9e, 0x0d, 0x45, 0x56, 0xc0, 0xcc,
     45 	0x3f, 0xdd, 0xbd, 0x2e, 0x0c, 0x11, 0xb6, 0x81, 0x14, 0xdb, 0x67, 0x78,
     46 	0x68, 0x7b, 0x0b, 0x3b, 0xf6, 0xb7, 0x00, 0x99, 0x5f, 0xda, 0xf9, 0x47,
     47 	0x97, 0xf7, 0x04, 0x8f, 0xda, 0x37, 0xbf, 0x9c, 0xbf, 0xa8, 0xe5, 0x57,
     48 	0x45, 0x7c, 0xc7, 0xf3, 0x51, 0x81, 0x95, 0xd4, 0x1b, 0xf1, 0x51, 0xfb,
     49 	0x7e, 0xad, 0xc3, 0x60, 0x78, 0x2e, 0x11, 0xe1, 0x6f, 0x10, 0x1c, 0x99,
     50 	0xe0, 0x43, 0x41, 0x58, 0x24, 0x5b, 0x0d, 0xd5, 0xae, 0x3e, 0x8b, 0x43,
     51 	0xf4, 0x1f, 0x11, 0x48, 0x16, 0xcf, 0x3b, 0x33, 0x05, 0x03, 0xdd, 0x03,
     52 	0x14, 0xe9, 0x22, 0x8b, 0xab, 0x2e, 0xe6, 0xd3, 0xaf, 0x9e, 0xf4, 0x16,
     53 	0xdf, 0xc8, 0x81, 0x21, 0xc4, 0x9e, 0x3e, 0xbd, 0x06, 0xb1, 0x7a, 0xd8,
     54 	0x3a, 0xb9, 0xd1, 0x74, 0x07, 0x2b, 0x99, 0xe6, 0x77, 0xe1, 0x99, 0x81,
     55 ];
     56 
     57 const sig256: [_]u8 = [
     58 	0x46, 0x31, 0xbd, 0xdb, 0xc9, 0x1a, 0xc4, 0x96, 0x05, 0x35, 0x8c, 0xba,
     59 	0xf0, 0xc0, 0x82, 0x84, 0xdc, 0x00, 0x5d, 0x43, 0xe2, 0x24, 0x43, 0x82,
     60 	0xee, 0xeb, 0x10, 0x69, 0xb8, 0x83, 0x07, 0xe8, 0xf9, 0x4a, 0x24, 0xbe,
     61 	0x8a, 0xb1, 0x19, 0xe3, 0x98, 0x72, 0x2f, 0x08, 0x29, 0x06, 0x6a, 0xbc,
     62 	0x9b, 0x0f, 0xa3, 0x83, 0x22, 0xe4, 0xf1, 0x8b, 0xcf, 0x56, 0xc5, 0x4e,
     63 	0x1f, 0x6e, 0xdf, 0xdd, 0x9e, 0xb3, 0x14, 0xe2, 0x59, 0xe8, 0x04, 0xd8,
     64 	0x4b, 0xd6, 0xed, 0x32, 0xfc, 0x3a, 0x07, 0xbb, 0xe1, 0xe4, 0xee, 0x6d,
     65 	0xb3, 0x23, 0x63, 0xa8, 0x8e, 0xc5, 0x97, 0xb9, 0xb2, 0x89, 0x68, 0x6a,
     66 	0x75, 0x13, 0x1e, 0xca, 0x8d, 0x62, 0x6d, 0x4c, 0xf1, 0x8f, 0x93, 0xd2,
     67 	0xac, 0x96, 0xf7, 0xd6, 0xde, 0xf7, 0xb2, 0x2c, 0xf8, 0x7d, 0x54, 0x31,
     68 	0x34, 0xe3, 0x50, 0xd5, 0x55, 0xc8, 0xa8, 0xce, 0x45, 0x78, 0xf4, 0xfc,
     69 	0xf4, 0x1d, 0x7d, 0xde, 0x9f, 0xb7, 0x7d, 0xc3, 0x1b, 0xfd, 0xb4, 0x5a,
     70 	0x1f, 0x7d, 0x69, 0x55, 0x5c, 0x76, 0x75, 0xd0, 0x14, 0x42, 0x28, 0xf9,
     71 	0x6b, 0xd0, 0x35, 0x9b, 0xe3, 0x9c, 0x64, 0xd0, 0x0d, 0x16, 0x5f, 0x66,
     72 	0x41, 0xe9, 0x84, 0x27, 0x60, 0xe6, 0x9e, 0x24, 0x7e, 0x89, 0xc5, 0x99,
     73 	0x4e, 0x3e, 0xfd, 0x6b, 0xcc, 0xa9, 0x99, 0xbe, 0x04, 0x9f, 0xd0, 0x8a,
     74 	0x97, 0x05, 0x36, 0x82, 0xc9, 0x00, 0x85, 0x1a, 0x1e, 0x6b, 0x02, 0x8e,
     75 	0xab, 0x5b, 0xfd, 0x52, 0x65, 0x7c, 0x95, 0x57, 0x35, 0xcc, 0x05, 0xe8,
     76 	0x82, 0x80, 0x42, 0x65, 0x1d, 0x04, 0xdc, 0x1c, 0x45, 0xf0, 0x91, 0x3a,
     77 	0x8c, 0x87, 0x44, 0xa3, 0x7b, 0x15, 0xe8, 0xfd, 0xb4, 0xb6, 0x56, 0x53,
     78 	0xaa, 0x5f, 0xdb, 0x3f, 0x46, 0x86, 0xb4, 0x97, 0xfb, 0x12, 0x73, 0xe0,
     79 	0xfc, 0x92, 0x0c, 0xcf, 0x80, 0x9f, 0x3b, 0x8b, 0x8a, 0xd0, 0x0e, 0x93,
     80 	0xd7, 0xcf, 0x87, 0xb7, 0xe2, 0x85, 0x83, 0x22, 0x18, 0x36, 0x31, 0xed,
     81 	0x5a, 0x75, 0xc0, 0xe3, 0x54, 0xcd, 0xf4, 0x55, 0xbd, 0xdc, 0xdc, 0x63,
     82 	0x9b, 0x48, 0x62, 0x6c, 0x59, 0x6d, 0xff, 0xe1, 0x23, 0xa1, 0x1f, 0xd2,
     83 	0xbd, 0x54, 0x90, 0xda, 0x3f, 0x1a, 0x02, 0xdd, 0xbd, 0x63, 0x46, 0x86,
     84 	0x7e, 0xda, 0x6c, 0x5e, 0xed, 0x18, 0x8f, 0x55, 0x70, 0xce, 0xba, 0x8f,
     85 	0xab, 0x25, 0xb4, 0x3a, 0xa2, 0x9d, 0xca, 0x6e, 0xd2, 0xb6, 0xb3, 0x8b,
     86 	0xb2, 0xcf, 0x4e, 0xa2, 0x84, 0x7e, 0xdf, 0xf0, 0x46, 0x28, 0x23, 0x90,
     87 	0x88, 0x0d, 0x12, 0x85, 0x39, 0xbc, 0xfc, 0x1d, 0x51, 0xee, 0x96, 0xca,
     88 	0x8b, 0x60, 0x99, 0xba, 0xa0, 0x77, 0x63, 0x05, 0xd7, 0xa4, 0xc6, 0x03,
     89 	0xc0, 0x1d, 0x6f, 0x69, 0xbe, 0x4b, 0x4a, 0xaf, 0xeb, 0x2b, 0xc8, 0xc6,
     90 ];
     91 
     92 const sig384: [_]u8 = [
     93 	0x0b, 0xed, 0x44, 0xc2, 0xb6, 0x97, 0xe0, 0xe2, 0x02, 0xb3, 0x66, 0x4f,
     94 	0x5b, 0x8d, 0xf0, 0xb8, 0x82, 0x0f, 0x4f, 0x28, 0x6d, 0xd4, 0x81, 0xb6,
     95 	0x24, 0x1f, 0x66, 0x1a, 0xa9, 0xa1, 0x8c, 0x4d, 0xc0, 0x11, 0x36, 0x03,
     96 	0xf9, 0x2d, 0x35, 0x6e, 0xc8, 0xeb, 0x95, 0x77, 0x86, 0xcf, 0xae, 0x4d,
     97 	0x40, 0xf5, 0xed, 0xef, 0x9b, 0x9c, 0x24, 0x2b, 0x89, 0x04, 0x89, 0x46,
     98 	0x2c, 0xbd, 0xea, 0x0a, 0xa9, 0xba, 0x50, 0x89, 0xc8, 0x52, 0x33, 0x63,
     99 	0xe4, 0xbf, 0x26, 0x4a, 0x57, 0x82, 0xc7, 0xc8, 0x5b, 0x9e, 0x64, 0x94,
    100 	0x1e, 0xe5, 0x26, 0x8a, 0xde, 0x6b, 0x63, 0xe1, 0x3f, 0xd8, 0x18, 0xf9,
    101 	0xcc, 0xe5, 0x33, 0x0d, 0x98, 0x41, 0xc3, 0xb5, 0x9a, 0x9c, 0x90, 0xb7,
    102 	0xe8, 0xc4, 0x68, 0xa0, 0xb8, 0x8d, 0x22, 0x5f, 0x5a, 0xe4, 0x53, 0xbf,
    103 	0x82, 0x08, 0x6e, 0x5f, 0xe1, 0xa5, 0xeb, 0x23, 0x8a, 0xc9, 0xe3, 0xeb,
    104 	0x6b, 0xd1, 0x6d, 0x95, 0x64, 0xc0, 0x25, 0x37, 0xc9, 0xb4, 0x14, 0x85,
    105 	0xa9, 0x7e, 0x44, 0xbc, 0x15, 0x56, 0xdb, 0x03, 0xac, 0x4d, 0x19, 0x61,
    106 	0x24, 0x5a, 0xc3, 0x48, 0x34, 0x72, 0xff, 0xc6, 0x97, 0xee, 0xf8, 0xf7,
    107 	0xdb, 0x07, 0xce, 0x47, 0x61, 0x53, 0x40, 0xe7, 0xf4, 0x2b, 0xca, 0xa0,
    108 	0xcc, 0xd6, 0xd8, 0x46, 0x5b, 0x88, 0xd9, 0xf0, 0xd9, 0x01, 0x87, 0x85,
    109 	0x33, 0x6b, 0x34, 0xb8, 0x34, 0xc8, 0x50, 0x86, 0x1f, 0xbe, 0xf9, 0xca,
    110 	0x07, 0x13, 0x2b, 0x31, 0x20, 0x92, 0xb2, 0xec, 0x31, 0xf0, 0xd1, 0x45,
    111 	0xab, 0x8c, 0xaa, 0x19, 0xb6, 0x81, 0x98, 0x31, 0x74, 0xd2, 0x96, 0x4e,
    112 	0x6a, 0xac, 0x90, 0xbe, 0xfe, 0xb7, 0xbb, 0x56, 0x3b, 0x72, 0x68, 0x0e,
    113 	0xc4, 0xef, 0x63, 0xc9, 0xfe, 0xe8, 0xa2, 0xf6, 0x92, 0x82, 0x05, 0x24,
    114 	0xf2, 0x52, 0xb0, 0x5a, 0x90, 0xdf, 0x04, 0xff, 0x6c, 0xb0, 0x79, 0x80,
    115 	0x28, 0xb0, 0x64, 0x08, 0x14, 0x93, 0x12, 0x02, 0x13, 0xd3, 0x6d, 0x8c,
    116 	0x9c, 0xfe, 0x42, 0x89, 0xcd, 0xc5, 0x94, 0x9f, 0x46, 0x72, 0xda, 0x49,
    117 	0x4d, 0xd9, 0xa6, 0x97, 0x21, 0x80, 0xa2, 0xfa, 0x57, 0x79, 0xd0, 0xc6,
    118 	0x83, 0x30, 0x29, 0x26, 0x09, 0x81, 0xba, 0x17, 0x60, 0x06, 0x31, 0x21,
    119 	0x6f, 0xfc, 0xf6, 0x53, 0x93, 0xe9, 0x7f, 0xe2, 0x64, 0x56, 0xd5, 0xf5,
    120 	0x11, 0x4f, 0x8b, 0xe1, 0xce, 0x3f, 0x41, 0x54, 0xf4, 0x5f, 0x08, 0xbc,
    121 	0xfd, 0x13, 0x21, 0x62, 0x99, 0x4a, 0x4e, 0x8c, 0x14, 0xd2, 0x80, 0xf0,
    122 	0x18, 0x9c, 0xbf, 0x3a, 0xb4, 0x80, 0x5b, 0x3d, 0x28, 0xa5, 0xbc, 0x12,
    123 	0x96, 0x9d, 0xa9, 0x92, 0x01, 0xbe, 0x62, 0xbb, 0xf6, 0x1f, 0x24, 0x37,
    124 	0xfa, 0xa2, 0xe4, 0x73, 0x65, 0x27, 0x0b, 0xc6, 0x95, 0x86, 0x2e, 0x46,
    125 ];
    126 
    127 const sig512: [_]u8 = [
    128 	0x6e, 0xb5, 0x5f, 0xbd, 0x48, 0x09, 0x08, 0x7c, 0x01, 0xb3, 0x74, 0x26,
    129 	0x73, 0x9d, 0x3e, 0xd5, 0x08, 0x7d, 0xe8, 0x11, 0x01, 0x21, 0x31, 0x11,
    130 	0x91, 0x34, 0x5b, 0xe5, 0x6c, 0x37, 0x79, 0x7b, 0xdb, 0x75, 0x16, 0x62,
    131 	0x0e, 0x7d, 0x1d, 0xd1, 0x04, 0x45, 0xbc, 0xa9, 0x79, 0xd0, 0xb1, 0x1d,
    132 	0x1e, 0x20, 0x65, 0x37, 0x92, 0x90, 0xa8, 0xd3, 0x5f, 0x07, 0x24, 0x54,
    133 	0x53, 0x97, 0x69, 0x84, 0xe2, 0xbb, 0xc0, 0xb5, 0x82, 0x4f, 0x29, 0xac,
    134 	0xc9, 0x07, 0xa7, 0x75, 0x08, 0x1c, 0x0c, 0x72, 0x9f, 0x35, 0x1b, 0x75,
    135 	0xb2, 0x79, 0x3f, 0x41, 0xa5, 0xcb, 0x9d, 0x69, 0x02, 0xa8, 0x08, 0xfe,
    136 	0x11, 0x19, 0x2f, 0xc2, 0xdb, 0x0e, 0xa6, 0xe0, 0xc4, 0x44, 0x33, 0xd6,
    137 	0xad, 0x59, 0x11, 0xa7, 0x38, 0xc0, 0xe7, 0x37, 0x21, 0xa8, 0x13, 0x96,
    138 	0xe9, 0x63, 0x25, 0xd9, 0x2e, 0xbf, 0x10, 0x59, 0x49, 0xdd, 0xc0, 0x55,
    139 	0xeb, 0x6d, 0xbe, 0x0a, 0x1e, 0xe2, 0x62, 0xce, 0x53, 0x2e, 0xaa, 0xed,
    140 	0xe5, 0x7e, 0xf7, 0x1b, 0xbb, 0x09, 0x75, 0x5e, 0x5f, 0xf9, 0x78, 0x12,
    141 	0x51, 0xa4, 0x63, 0x52, 0xa4, 0xba, 0x45, 0xbc, 0x48, 0x89, 0xb2, 0x73,
    142 	0xb4, 0xa5, 0x25, 0xd3, 0x1a, 0xd5, 0x9d, 0xff, 0x4e, 0xba, 0xd0, 0xb0,
    143 	0xb5, 0x21, 0x11, 0x25, 0x4d, 0x84, 0x90, 0x6e, 0xcd, 0x68, 0xd6, 0xd7,
    144 	0x39, 0xf7, 0x03, 0xb5, 0x7e, 0x78, 0x7e, 0x33, 0x2c, 0x7f, 0x34, 0x8f,
    145 	0x6f, 0xb2, 0x24, 0xe0, 0x5f, 0xd6, 0x18, 0x42, 0x4d, 0xb4, 0x5b, 0xe5,
    146 	0xc6, 0x92, 0xde, 0x54, 0x37, 0x69, 0x36, 0x7d, 0xe0, 0x0b, 0xa2, 0x6a,
    147 	0xb7, 0x41, 0xf4, 0x23, 0x09, 0x7f, 0x26, 0x64, 0xff, 0x10, 0x8a, 0x28,
    148 	0x34, 0xca, 0x08, 0x81, 0xf5, 0x38, 0x58, 0x46, 0xd2, 0xc0, 0x1c, 0x35,
    149 	0x31, 0x69, 0xcc, 0x4a, 0xed, 0x04, 0x22, 0x06, 0xbf, 0x79, 0x62, 0x0e,
    150 	0x43, 0x5e, 0x90, 0xf3, 0x95, 0x6b, 0x6e, 0xc3, 0x80, 0x9c, 0x63, 0xd1,
    151 	0xf7, 0xf2, 0x9f, 0x83, 0xb2, 0x09, 0x08, 0xcf, 0xb3, 0x87, 0x79, 0xc6,
    152 	0x24, 0xe6, 0x98, 0x58, 0xda, 0xdc, 0x0c, 0x67, 0x4c, 0x1f, 0xe7, 0xc3,
    153 	0x26, 0xec, 0xdd, 0x7e, 0x91, 0xb0, 0x31, 0x99, 0x5c, 0x93, 0x52, 0x17,
    154 	0xa2, 0x0f, 0xb1, 0xfb, 0x09, 0xd2, 0xa9, 0xe5, 0xdf, 0x1e, 0x5c, 0xa8,
    155 	0xf5, 0x0c, 0x20, 0xc3, 0xe3, 0x07, 0x32, 0x1b, 0x42, 0xc1, 0x58, 0xb2,
    156 	0x1c, 0x52, 0x7d, 0x56, 0xf8, 0x0c, 0xad, 0x03, 0xf5, 0x40, 0x07, 0x9c,
    157 	0xf4, 0x41, 0xf5, 0x54, 0xed, 0x66, 0x11, 0xd6, 0x98, 0xa4, 0x32, 0xd2,
    158 	0x94, 0x02, 0x74, 0xa9, 0xe1, 0x3a, 0x61, 0x18, 0x37, 0x54, 0xce, 0x03,
    159 	0x17, 0xc9, 0xc9, 0x99, 0x22, 0xd7, 0x3f, 0x71, 0x7f, 0xf5, 0x8d, 0xa3,
    160 ];
    161 
    162 const sig512_224: [_]u8 = [
    163 	0x65, 0xda, 0xf7, 0x42, 0x16, 0xe9, 0xcb, 0xc0, 0xed, 0x1e, 0xb7, 0xf1,
    164 	0x18, 0xab, 0x30, 0xf4, 0xe9, 0xf3, 0x4c, 0x1f, 0x8f, 0x94, 0x61, 0x79,
    165 	0xe1, 0x89, 0x89, 0xbb, 0x6d, 0x26, 0xcb, 0xfc, 0xaf, 0x99, 0xdc, 0x6b,
    166 	0x16, 0x4c, 0x51, 0x4f, 0x49, 0xb0, 0xd8, 0x98, 0x89, 0x95, 0x10, 0x6f,
    167 	0xa2, 0x50, 0x6e, 0x04, 0xaa, 0x98, 0xd7, 0x63, 0x91, 0x21, 0x8f, 0x5a,
    168 	0xd5, 0xd1, 0x9c, 0x31, 0xe2, 0x0c, 0xd1, 0xb1, 0xf8, 0xf5, 0x06, 0x75,
    169 	0x50, 0x33, 0x31, 0x49, 0xa4, 0xac, 0x87, 0x75, 0x1b, 0x03, 0x12, 0x27,
    170 	0x23, 0xbf, 0xe5, 0xe5, 0xcf, 0xa6, 0x33, 0xeb, 0xa3, 0x20, 0xbd, 0xc7,
    171 	0x21, 0x89, 0x4a, 0x66, 0x8a, 0x0d, 0xe4, 0x29, 0x7f, 0x39, 0xe1, 0x21,
    172 	0x7e, 0x2d, 0x23, 0x26, 0xe0, 0xae, 0xc9, 0xb7, 0xb6, 0xce, 0x85, 0x2d,
    173 	0x9e, 0x98, 0xc0, 0x02, 0x6c, 0x4e, 0x81, 0xcf, 0x4f, 0xea, 0x85, 0x66,
    174 	0xae, 0x4a, 0xca, 0xf9, 0x48, 0x35, 0x0c, 0xb4, 0x33, 0x30, 0xb9, 0x60,
    175 	0xc3, 0x9b, 0xb7, 0x02, 0x81, 0x02, 0xb2, 0x85, 0xcf, 0x64, 0x41, 0xa9,
    176 	0xc9, 0xf1, 0x71, 0x04, 0xef, 0xe1, 0x27, 0xbd, 0x8d, 0xd6, 0x16, 0xb3,
    177 	0xfc, 0x2e, 0xf3, 0x5b, 0xfa, 0xb1, 0xa3, 0xfd, 0x22, 0x58, 0xda, 0xaf,
    178 	0x0c, 0x3b, 0xf4, 0x9c, 0xa9, 0x53, 0x0c, 0x96, 0x2f, 0x73, 0x9f, 0x74,
    179 	0xb3, 0x03, 0xf6, 0xb6, 0x4e, 0xcb, 0x40, 0xed, 0xb3, 0x1b, 0x1c, 0x53,
    180 	0x19, 0xf7, 0x78, 0xb0, 0x59, 0x05, 0xd5, 0x1b, 0x5e, 0xb9, 0xaf, 0x23,
    181 	0xdd, 0xa9, 0xc4, 0x2d, 0x6f, 0x09, 0x67, 0xcb, 0x5d, 0x9e, 0x03, 0xfb,
    182 	0xe6, 0x70, 0x72, 0xef, 0x62, 0xb8, 0x50, 0xad, 0x70, 0xb1, 0x34, 0xfd,
    183 	0x92, 0x0f, 0xb1, 0xfd, 0x8a, 0x37, 0x63, 0x93, 0xa2, 0x9b, 0x2c, 0x9b,
    184 	0x62, 0xe6, 0x95, 0x3a, 0xfb, 0x44, 0x4c, 0xf5, 0x96, 0x2b, 0x9f, 0x7a,
    185 	0x6f, 0xae, 0xc4, 0xa5, 0xe4, 0x23, 0x3b, 0x06, 0xf5, 0x95, 0x89, 0xa6,
    186 	0x15, 0xb1, 0xd5, 0xa3, 0xdd, 0x2c, 0x17, 0xf5, 0x60, 0x5d, 0x09, 0x69,
    187 	0x42, 0x88, 0xe7, 0x21, 0x60, 0x79, 0xe9, 0x69, 0x9d, 0x12, 0x2e, 0x6a,
    188 	0xdf, 0x51, 0x45, 0x54, 0x91, 0x54, 0x17, 0xe7, 0x6c, 0x8c, 0xbf, 0xe3,
    189 	0x69, 0xc2, 0xfa, 0xb4, 0x7b, 0x72, 0xda, 0x48, 0xe4, 0xd1, 0xce, 0x86,
    190 	0x8f, 0x17, 0x5d, 0x18, 0x21, 0x72, 0x28, 0x8a, 0x78, 0xca, 0xa1, 0x90,
    191 	0x6b, 0x6d, 0xc0, 0x39, 0xb3, 0xe9, 0x71, 0x65, 0xe8, 0xbb, 0x19, 0xf4,
    192 	0x8b, 0x59, 0xc2, 0x9e, 0x7b, 0xa3, 0xf2, 0xcb, 0x0d, 0xa0, 0xb4, 0x32,
    193 	0xe2, 0xdb, 0x72, 0x5c, 0x7f, 0xe2, 0x32, 0x77, 0x62, 0xf1, 0xb9, 0x34,
    194 	0xe9, 0x95, 0x8d, 0x76, 0xa4, 0xf2, 0xd2, 0x31, 0x46, 0xc1, 0xf9, 0xdb,
    195 ];
    196 
    197 const sig512_256: [_]u8 = [
    198 	0xb9, 0x33, 0xe4, 0x78, 0x0f, 0x91, 0xa3, 0xe4, 0x2c, 0x34, 0x9a, 0xfc,
    199 	0x00, 0xba, 0x37, 0x8e, 0x1f, 0x94, 0xe4, 0xf2, 0xae, 0x75, 0x96, 0x9f,
    200 	0xe1, 0x9c, 0xef, 0xf9, 0x72, 0x50, 0x21, 0x3b, 0xe6, 0xef, 0xa5, 0x3e,
    201 	0x04, 0x9e, 0x75, 0x25, 0x1a, 0x2c, 0xa1, 0x74, 0x26, 0x74, 0x20, 0x57,
    202 	0x2c, 0xda, 0x83, 0x1f, 0x21, 0xb0, 0x07, 0x0a, 0x88, 0xd3, 0x1d, 0x0c,
    203 	0x59, 0xef, 0x93, 0x1d, 0x38, 0xe6, 0xe8, 0x77, 0x3a, 0x70, 0xad, 0xb2,
    204 	0xcd, 0x9e, 0x3b, 0xf0, 0x48, 0xfd, 0x49, 0xe7, 0x06, 0x8e, 0x6d, 0x16,
    205 	0x01, 0x44, 0x8f, 0xbd, 0x74, 0x96, 0xae, 0xc6, 0x6f, 0x03, 0x7f, 0xc2,
    206 	0xb1, 0x0c, 0x00, 0x45, 0xbe, 0x14, 0x1a, 0xdc, 0xa2, 0xe8, 0x61, 0xaf,
    207 	0x03, 0x39, 0x5a, 0xa9, 0x6c, 0xf2, 0xa7, 0x31, 0x95, 0x91, 0x4f, 0xf2,
    208 	0xff, 0x93, 0x03, 0xac, 0x8e, 0xe7, 0x1c, 0xd7, 0xae, 0x71, 0x9a, 0x5d,
    209 	0x0e, 0xb6, 0xed, 0x99, 0x24, 0x8c, 0xec, 0x95, 0x9e, 0x98, 0xf6, 0x04,
    210 	0xb8, 0xa9, 0x36, 0x64, 0xbe, 0xdd, 0x3d, 0x9f, 0x59, 0xed, 0x7d, 0x51,
    211 	0x5b, 0x1a, 0xb5, 0x68, 0x00, 0xa1, 0x5f, 0x0e, 0xdb, 0xb1, 0xd5, 0x43,
    212 	0x4f, 0xd7, 0x2e, 0xc7, 0x61, 0x86, 0xdb, 0x21, 0xaf, 0xa7, 0xd3, 0x0f,
    213 	0xb6, 0xa2, 0x59, 0x34, 0x86, 0xeb, 0xe6, 0x2e, 0x44, 0xb3, 0x2c, 0xea,
    214 	0x1c, 0x47, 0x7c, 0x81, 0x54, 0xba, 0x4a, 0x3a, 0x89, 0x63, 0x1e, 0x2f,
    215 	0x10, 0x2b, 0x96, 0xd2, 0x54, 0x76, 0xa3, 0xd8, 0x2c, 0x41, 0xb8, 0xaa,
    216 	0xd0, 0x35, 0xf0, 0x00, 0xf6, 0xba, 0x82, 0x4d, 0xe4, 0xe7, 0x5a, 0xfc,
    217 	0x2e, 0xc6, 0x03, 0x2e, 0x9e, 0x90, 0x0c, 0x37, 0xa8, 0xff, 0x87, 0xa7,
    218 	0x78, 0x2f, 0x68, 0xd2, 0x85, 0xa8, 0xf2, 0x93, 0x88, 0x2a, 0x90, 0x03,
    219 	0xe1, 0x4a, 0x2e, 0x58, 0x63, 0x92, 0x21, 0xf2, 0x8c, 0x3d, 0xdd, 0x49,
    220 	0xc1, 0x0e, 0x15, 0x1b, 0xcf, 0x21, 0xd5, 0x0d, 0x24, 0xba, 0xd6, 0x29,
    221 	0xdb, 0xb3, 0x53, 0xfc, 0x56, 0xa9, 0x55, 0xb6, 0x1e, 0x8d, 0xd5, 0xd7,
    222 	0x16, 0x0c, 0x65, 0x53, 0xc7, 0xda, 0xc7, 0x8b, 0x35, 0x99, 0x38, 0x80,
    223 	0xa8, 0xe7, 0x5e, 0x57, 0x60, 0xad, 0x24, 0xe6, 0x0c, 0x4c, 0xa3, 0xbf,
    224 	0xe5, 0x79, 0x9c, 0x1b, 0xa2, 0x1f, 0x6c, 0xf4, 0x4b, 0x50, 0x36, 0x15,
    225 	0xf7, 0x9b, 0xab, 0x17, 0x8f, 0x15, 0x1f, 0x5b, 0x93, 0x67, 0x56, 0x70,
    226 	0x5c, 0x5b, 0x59, 0xef, 0x1b, 0x41, 0xf9, 0x36, 0xc5, 0x6f, 0x49, 0x1e,
    227 	0x2f, 0x99, 0xdd, 0x13, 0xb6, 0xd1, 0x2b, 0xb9, 0x68, 0x36, 0xbf, 0x02,
    228 	0xd6, 0x27, 0x6f, 0xeb, 0x83, 0x8a, 0x77, 0x12, 0xf7, 0x07, 0xd8, 0x3f,
    229 	0x60, 0x57, 0x5b, 0x24, 0x73, 0x64, 0x85, 0x90, 0xf0, 0xbd, 0x76, 0xcd,
    230 ];
    231 
    232 @test fn pkcs1() void = {
    233 	let pk = sign3072.priv;
    234 	let priv: [PRIVKEYSZ]u8 = [0...];
    235 	privkey_init(priv, sign3072.priv)!;
    236 
    237 	let pub: [PUBKEYSZ]u8 = [0...];
    238 	pubkey_init(pub, sign3072.pub)!;
    239 
    240 	assertpkcs1(priv, pub, msg, sig1, pkcs1_hashalgo::SHA1);
    241 	assertpkcs1(priv, pub, msg, sig256, pkcs1_hashalgo::SHA256);
    242 	assertpkcs1(priv, pub, msg, sig384, pkcs1_hashalgo::SHA384);
    243 	assertpkcs1(priv, pub, msg, sig512, pkcs1_hashalgo::SHA512);
    244 	assertpkcs1(priv, pub, msg, sig512_224, pkcs1_hashalgo::SHA512_224);
    245 	assertpkcs1(priv, pub, msg, sig512_256, pkcs1_hashalgo::SHA512_256);
    246 };
    247 
    248 fn assertpkcs1(
    249 	priv: []u8,
    250 	pub: []u8,
    251 	msg: []u8,
    252 	sig: []u8,
    253 	algo: pkcs1_hashalgo
    254 ) void = {
    255 	let nsig: []u8 = alloc([0...], len(sig));
    256 	defer free(nsig);
    257 
    258 	let msghash = pkcs1_hash(msg, algo);
    259 	defer free(msghash);
    260 
    261 	pkcs1_sign(priv, msghash, nsig, algo, pkcs1_signbuf)!;
    262 	assert(bytes::equal(nsig, sig));
    263 
    264 	pkcs1_verify(pub, msghash, sig, algo, pkcs1_verifybuf)!;
    265 
    266 	const tmp = msghash[0];
    267 	msghash[0] += 1;
    268 	assert(pkcs1_verify(pub, msghash, sig, algo, pkcs1_verifybuf) is error);
    269 
    270 	msghash[0] = tmp;
    271 	nsig[0] += 1;
    272 	assert(pkcs1_verify(pub, msghash, nsig, algo, pkcs1_verifybuf) is error);
    273 };
    274 
    275 fn pkcs1_hash(msg: []u8, algo: pkcs1_hashalgo) []u8 = {
    276 	let h: *hash::hash = switch (algo) {
    277 	case pkcs1_hashalgo::SHA1 =>
    278 		yield &sha1::sha1();
    279 	case pkcs1_hashalgo::SHA256 =>
    280 		yield &sha256::sha256();
    281 	case pkcs1_hashalgo::SHA384 =>
    282 		yield &sha512::sha384();
    283 	case pkcs1_hashalgo::SHA512 =>
    284 		yield &sha512::sha512();
    285 	case pkcs1_hashalgo::SHA512_224 =>
    286 		yield &sha512::sha512_224();
    287 	case pkcs1_hashalgo::SHA512_256 =>
    288 		yield &sha512::sha512_256();
    289 	case =>
    290 		abort("unreachable");
    291 	};
    292 	defer hash::close(h);
    293 	let out: []u8 = alloc([0...], hash::sz(h));
    294 
    295 	io::writeall(h, msg)!;
    296 	hash::sum(h, out);
    297 	return out;
    298 };