comparison libtomcrypt/src/pk/asn1/der/ia5/der_length_ia5_string.c @ 1471:6dba84798cd5

Update to libtomcrypt 1.18.1, merged with Dropbear changes
author Matt Johnston <matt@ucc.asn.au>
date Fri, 09 Feb 2018 21:44:05 +0800
parents f849a5ca2efc
children
comparison
equal deleted inserted replaced
1470:8bba51a55704 1471:6dba84798cd5
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_ia5_string.c 12 @file der_length_ia5_string.c
19 17
20 static const struct { 18 static const struct {
21 int code, value; 19 int code, value;
22 } ia5_table[] = { 20 } ia5_table[] = {
23 { '\0', 0 }, 21 { '\0', 0 },
24 { '\a', 7 }, 22 { '\a', 7 },
25 { '\b', 8 }, 23 { '\b', 8 },
26 { '\t', 9 }, 24 { '\t', 9 },
27 { '\n', 10 }, 25 { '\n', 10 },
28 { '\f', 12 }, 26 { '\f', 12 },
29 { '\r', 13 }, 27 { '\r', 13 },
30 { ' ', 32 }, 28 { ' ', 32 },
31 { '!', 33 }, 29 { '!', 33 },
32 { '"', 34 }, 30 { '"', 34 },
33 { '#', 35 }, 31 { '#', 35 },
34 { '$', 36 }, 32 { '$', 36 },
35 { '%', 37 }, 33 { '%', 37 },
36 { '&', 38 }, 34 { '&', 38 },
37 { '\'', 39 }, 35 { '\'', 39 },
38 { '(', 40 }, 36 { '(', 40 },
39 { ')', 41 }, 37 { ')', 41 },
40 { '*', 42 }, 38 { '*', 42 },
41 { '+', 43 }, 39 { '+', 43 },
42 { ',', 44 }, 40 { ',', 44 },
43 { '-', 45 }, 41 { '-', 45 },
44 { '.', 46 }, 42 { '.', 46 },
45 { '/', 47 }, 43 { '/', 47 },
46 { '0', 48 }, 44 { '0', 48 },
47 { '1', 49 }, 45 { '1', 49 },
48 { '2', 50 }, 46 { '2', 50 },
49 { '3', 51 }, 47 { '3', 51 },
50 { '4', 52 }, 48 { '4', 52 },
51 { '5', 53 }, 49 { '5', 53 },
52 { '6', 54 }, 50 { '6', 54 },
53 { '7', 55 }, 51 { '7', 55 },
54 { '8', 56 }, 52 { '8', 56 },
55 { '9', 57 }, 53 { '9', 57 },
56 { ':', 58 }, 54 { ':', 58 },
57 { ';', 59 }, 55 { ';', 59 },
58 { '<', 60 }, 56 { '<', 60 },
59 { '=', 61 }, 57 { '=', 61 },
60 { '>', 62 }, 58 { '>', 62 },
61 { '?', 63 }, 59 { '?', 63 },
62 { '@', 64 }, 60 { '@', 64 },
63 { 'A', 65 }, 61 { 'A', 65 },
64 { 'B', 66 }, 62 { 'B', 66 },
65 { 'C', 67 }, 63 { 'C', 67 },
66 { 'D', 68 }, 64 { 'D', 68 },
67 { 'E', 69 }, 65 { 'E', 69 },
68 { 'F', 70 }, 66 { 'F', 70 },
69 { 'G', 71 }, 67 { 'G', 71 },
70 { 'H', 72 }, 68 { 'H', 72 },
71 { 'I', 73 }, 69 { 'I', 73 },
72 { 'J', 74 }, 70 { 'J', 74 },
73 { 'K', 75 }, 71 { 'K', 75 },
74 { 'L', 76 }, 72 { 'L', 76 },
75 { 'M', 77 }, 73 { 'M', 77 },
76 { 'N', 78 }, 74 { 'N', 78 },
77 { 'O', 79 }, 75 { 'O', 79 },
78 { 'P', 80 }, 76 { 'P', 80 },
79 { 'Q', 81 }, 77 { 'Q', 81 },
80 { 'R', 82 }, 78 { 'R', 82 },
81 { 'S', 83 }, 79 { 'S', 83 },
82 { 'T', 84 }, 80 { 'T', 84 },
83 { 'U', 85 }, 81 { 'U', 85 },
84 { 'V', 86 }, 82 { 'V', 86 },
85 { 'W', 87 }, 83 { 'W', 87 },
86 { 'X', 88 }, 84 { 'X', 88 },
87 { 'Y', 89 }, 85 { 'Y', 89 },
88 { 'Z', 90 }, 86 { 'Z', 90 },
89 { '[', 91 }, 87 { '[', 91 },
90 { '\\', 92 }, 88 { '\\', 92 },
91 { ']', 93 }, 89 { ']', 93 },
92 { '^', 94 }, 90 { '^', 94 },
93 { '_', 95 }, 91 { '_', 95 },
94 { '`', 96 }, 92 { '`', 96 },
95 { 'a', 97 }, 93 { 'a', 97 },
96 { 'b', 98 }, 94 { 'b', 98 },
97 { 'c', 99 }, 95 { 'c', 99 },
98 { 'd', 100 }, 96 { 'd', 100 },
99 { 'e', 101 }, 97 { 'e', 101 },
100 { 'f', 102 }, 98 { 'f', 102 },
101 { 'g', 103 }, 99 { 'g', 103 },
102 { 'h', 104 }, 100 { 'h', 104 },
103 { 'i', 105 }, 101 { 'i', 105 },
104 { 'j', 106 }, 102 { 'j', 106 },
105 { 'k', 107 }, 103 { 'k', 107 },
106 { 'l', 108 }, 104 { 'l', 108 },
107 { 'm', 109 }, 105 { 'm', 109 },
108 { 'n', 110 }, 106 { 'n', 110 },
109 { 'o', 111 }, 107 { 'o', 111 },
110 { 'p', 112 }, 108 { 'p', 112 },
111 { 'q', 113 }, 109 { 'q', 113 },
112 { 'r', 114 }, 110 { 'r', 114 },
113 { 's', 115 }, 111 { 's', 115 },
114 { 't', 116 }, 112 { 't', 116 },
115 { 'u', 117 }, 113 { 'u', 117 },
116 { 'v', 118 }, 114 { 'v', 118 },
117 { 'w', 119 }, 115 { 'w', 119 },
118 { 'x', 120 }, 116 { 'x', 120 },
119 { 'y', 121 }, 117 { 'y', 121 },
120 { 'z', 122 }, 118 { 'z', 122 },
121 { '{', 123 }, 119 { '{', 123 },
122 { '|', 124 }, 120 { '|', 124 },
123 { '}', 125 }, 121 { '}', 125 },
124 { '~', 126 } 122 { '~', 126 }
125 }; 123 };
126 124
127 int der_ia5_char_encode(int c) 125 int der_ia5_char_encode(int c)
128 { 126 {
143 return ia5_table[x].code; 141 return ia5_table[x].code;
144 } 142 }
145 } 143 }
146 return -1; 144 return -1;
147 } 145 }
148 146
149 /** 147 /**
150 Gets length of DER encoding of IA5 STRING 148 Gets length of DER encoding of IA5 STRING
151 @param octets The values you want to encode 149 @param octets The values you want to encode
152 @param noctets The number of octets in the string to encode 150 @param noctets The number of octets in the string to encode
153 @param outlen [out] The length of the DER encoding for the given string 151 @param outlen [out] The length of the DER encoding for the given string
154 @return CRYPT_OK if successful 152 @return CRYPT_OK if successful
155 */ 153 */
156 int der_length_ia5_string(const unsigned char *octets, unsigned long noctets, unsigned long *outlen) 154 int der_length_ia5_string(const unsigned char *octets, unsigned long noctets, unsigned long *outlen)
187 } 185 }
188 186
189 #endif 187 #endif
190 188
191 189
192 /* $Source$ */ 190 /* ref: $Format:%D$ */
193 /* $Revision$ */ 191 /* git commit: $Format:%H$ */
194 /* $Date$ */ 192 /* commit time: $Format:%ai$ */