Mercurial > dropbear
comparison libtomcrypt/src/pk/asn1/der/printable_string/der_length_printable_string.c @ 1511:5916af64acd4 fuzz
merge from main
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 17 Feb 2018 19:29:51 +0800 |
parents | 6dba84798cd5 |
children |
comparison
equal
deleted
inserted
replaced
1457:32f990cc96b1 | 1511:5916af64acd4 |
---|---|
3 * LibTomCrypt is a library that provides various cryptographic | 3 * LibTomCrypt is a library that provides various cryptographic |
4 * algorithms in a highly modular and flexible manner. | 4 * algorithms in a highly modular and flexible manner. |
5 * | 5 * |
6 * The library is free for all purposes without any express | 6 * The library is free for all purposes without any express |
7 * guarantee it works. | 7 * guarantee it works. |
8 * | |
9 * Tom St Denis, [email protected], http://libtom.org | |
10 */ | 8 */ |
11 #include "tomcrypt.h" | 9 #include "tomcrypt.h" |
12 | 10 |
13 /** | 11 /** |
14 @file der_length_printable_string.c | 12 @file der_length_printable_string.c |
18 #ifdef LTC_DER | 16 #ifdef LTC_DER |
19 | 17 |
20 static const struct { | 18 static const struct { |
21 int code, value; | 19 int code, value; |
22 } printable_table[] = { | 20 } printable_table[] = { |
23 { ' ', 32 }, | 21 { ' ', 32 }, |
24 { '\'', 39 }, | 22 { '\'', 39 }, |
25 { '(', 40 }, | 23 { '(', 40 }, |
26 { ')', 41 }, | 24 { ')', 41 }, |
27 { '+', 43 }, | 25 { '+', 43 }, |
28 { ',', 44 }, | 26 { ',', 44 }, |
29 { '-', 45 }, | 27 { '-', 45 }, |
30 { '.', 46 }, | 28 { '.', 46 }, |
31 { '/', 47 }, | 29 { '/', 47 }, |
32 { '0', 48 }, | 30 { '0', 48 }, |
33 { '1', 49 }, | 31 { '1', 49 }, |
34 { '2', 50 }, | 32 { '2', 50 }, |
35 { '3', 51 }, | 33 { '3', 51 }, |
36 { '4', 52 }, | 34 { '4', 52 }, |
37 { '5', 53 }, | 35 { '5', 53 }, |
38 { '6', 54 }, | 36 { '6', 54 }, |
39 { '7', 55 }, | 37 { '7', 55 }, |
40 { '8', 56 }, | 38 { '8', 56 }, |
41 { '9', 57 }, | 39 { '9', 57 }, |
42 { ':', 58 }, | 40 { ':', 58 }, |
43 { '=', 61 }, | 41 { '=', 61 }, |
44 { '?', 63 }, | 42 { '?', 63 }, |
45 { 'A', 65 }, | 43 { 'A', 65 }, |
46 { 'B', 66 }, | 44 { 'B', 66 }, |
47 { 'C', 67 }, | 45 { 'C', 67 }, |
48 { 'D', 68 }, | 46 { 'D', 68 }, |
49 { 'E', 69 }, | 47 { 'E', 69 }, |
50 { 'F', 70 }, | 48 { 'F', 70 }, |
51 { 'G', 71 }, | 49 { 'G', 71 }, |
52 { 'H', 72 }, | 50 { 'H', 72 }, |
53 { 'I', 73 }, | 51 { 'I', 73 }, |
54 { 'J', 74 }, | 52 { 'J', 74 }, |
55 { 'K', 75 }, | 53 { 'K', 75 }, |
56 { 'L', 76 }, | 54 { 'L', 76 }, |
57 { 'M', 77 }, | 55 { 'M', 77 }, |
58 { 'N', 78 }, | 56 { 'N', 78 }, |
59 { 'O', 79 }, | 57 { 'O', 79 }, |
60 { 'P', 80 }, | 58 { 'P', 80 }, |
61 { 'Q', 81 }, | 59 { 'Q', 81 }, |
62 { 'R', 82 }, | 60 { 'R', 82 }, |
63 { 'S', 83 }, | 61 { 'S', 83 }, |
64 { 'T', 84 }, | 62 { 'T', 84 }, |
65 { 'U', 85 }, | 63 { 'U', 85 }, |
66 { 'V', 86 }, | 64 { 'V', 86 }, |
67 { 'W', 87 }, | 65 { 'W', 87 }, |
68 { 'X', 88 }, | 66 { 'X', 88 }, |
69 { 'Y', 89 }, | 67 { 'Y', 89 }, |
70 { 'Z', 90 }, | 68 { 'Z', 90 }, |
71 { 'a', 97 }, | 69 { 'a', 97 }, |
72 { 'b', 98 }, | 70 { 'b', 98 }, |
73 { 'c', 99 }, | 71 { 'c', 99 }, |
74 { 'd', 100 }, | 72 { 'd', 100 }, |
75 { 'e', 101 }, | 73 { 'e', 101 }, |
76 { 'f', 102 }, | 74 { 'f', 102 }, |
77 { 'g', 103 }, | 75 { 'g', 103 }, |
78 { 'h', 104 }, | 76 { 'h', 104 }, |
79 { 'i', 105 }, | 77 { 'i', 105 }, |
80 { 'j', 106 }, | 78 { 'j', 106 }, |
81 { 'k', 107 }, | 79 { 'k', 107 }, |
82 { 'l', 108 }, | 80 { 'l', 108 }, |
83 { 'm', 109 }, | 81 { 'm', 109 }, |
84 { 'n', 110 }, | 82 { 'n', 110 }, |
85 { 'o', 111 }, | 83 { 'o', 111 }, |
86 { 'p', 112 }, | 84 { 'p', 112 }, |
87 { 'q', 113 }, | 85 { 'q', 113 }, |
88 { 'r', 114 }, | 86 { 'r', 114 }, |
89 { 's', 115 }, | 87 { 's', 115 }, |
90 { 't', 116 }, | 88 { 't', 116 }, |
91 { 'u', 117 }, | 89 { 'u', 117 }, |
92 { 'v', 118 }, | 90 { 'v', 118 }, |
93 { 'w', 119 }, | 91 { 'w', 119 }, |
94 { 'x', 120 }, | 92 { 'x', 120 }, |
95 { 'y', 121 }, | 93 { 'y', 121 }, |
96 { 'z', 122 }, | 94 { 'z', 122 }, |
97 }; | 95 }; |
98 | 96 |
99 int der_printable_char_encode(int c) | 97 int der_printable_char_encode(int c) |
100 { | 98 { |
101 int x; | 99 int x; |
115 return printable_table[x].code; | 113 return printable_table[x].code; |
116 } | 114 } |
117 } | 115 } |
118 return -1; | 116 return -1; |
119 } | 117 } |
120 | 118 |
121 /** | 119 /** |
122 Gets length of DER encoding of Printable STRING | 120 Gets length of DER encoding of Printable STRING |
123 @param octets The values you want to encode | 121 @param octets The values you want to encode |
124 @param noctets The number of octets in the string to encode | 122 @param noctets The number of octets in the string to encode |
125 @param outlen [out] The length of the DER encoding for the given string | 123 @param outlen [out] The length of the DER encoding for the given string |
126 @return CRYPT_OK if successful | 124 @return CRYPT_OK if successful |
127 */ | 125 */ |
128 int der_length_printable_string(const unsigned char *octets, unsigned long noctets, unsigned long *outlen) | 126 int der_length_printable_string(const unsigned char *octets, unsigned long noctets, unsigned long *outlen) |
159 } | 157 } |
160 | 158 |
161 #endif | 159 #endif |
162 | 160 |
163 | 161 |
164 /* $Source$ */ | 162 /* ref: $Format:%D$ */ |
165 /* $Revision$ */ | 163 /* git commit: $Format:%H$ */ |
166 /* $Date$ */ | 164 /* commit time: $Format:%ai$ */ |