summaryrefslogtreecommitdiffstats
path: root/3rd_party/libsrp6a-sha512/t_conv.c
diff options
context:
space:
mode:
Diffstat (limited to '3rd_party/libsrp6a-sha512/t_conv.c')
-rw-r--r--3rd_party/libsrp6a-sha512/t_conv.c35
1 files changed, 8 insertions, 27 deletions
diff --git a/3rd_party/libsrp6a-sha512/t_conv.c b/3rd_party/libsrp6a-sha512/t_conv.c
index f7f50e2..76d4e58 100644
--- a/3rd_party/libsrp6a-sha512/t_conv.c
+++ b/3rd_party/libsrp6a-sha512/t_conv.c
@@ -33,8 +33,7 @@
33#include "cstr.h" 33#include "cstr.h"
34 34
35static int 35static int
36hexDigitToInt(c) 36hexDigitToInt(char c)
37 char c;
38{ 37{
39 if(c >= '0' && c <= '9') 38 if(c >= '0' && c <= '9')
40 return c - '0'; 39 return c - '0';
@@ -50,9 +49,7 @@ hexDigitToInt(c)
50 * Convert a hex string to a string of bytes; return size of dst 49 * Convert a hex string to a string of bytes; return size of dst
51 */ 50 */
52_TYPE( int ) 51_TYPE( int )
53t_fromhex(dst, src) 52t_fromhex(char *dst, const char *src)
54 char * dst;
55 const char * src;
56{ 53{
57 register char *chp = dst; 54 register char *chp = dst;
58 register unsigned size = strlen(src); 55 register unsigned size = strlen(src);
@@ -76,10 +73,7 @@ t_fromhex(dst, src)
76 * Convert a string of bytes to their hex representation 73 * Convert a string of bytes to their hex representation
77 */ 74 */
78_TYPE( char * ) 75_TYPE( char * )
79t_tohex(dst, src, size) 76t_tohex(char *dst, const char *src, unsigned size)
80 char * dst;
81 const char * src;
82 unsigned size;
83{ 77{
84 int notleading = 0; 78 int notleading = 0;
85 79
@@ -103,10 +97,7 @@ t_tohex(dst, src, size)
103} 97}
104 98
105_TYPE( char * ) 99_TYPE( char * )
106t_tohexcstr(dst, src, size) 100t_tohexcstr(cstr *dst, const char *src, unsigned size)
107 cstr * dst;
108 const char * src;
109 unsigned size;
110{ 101{
111 cstr_set_length(dst, 2 * size + 1); 102 cstr_set_length(dst, 2 * size + 1);
112 return t_tohex(dst->data, src, size); 103 return t_tohex(dst->data, src, size);
@@ -119,9 +110,7 @@ static char b64table[] =
119 * Convert a base64 string into raw byte array representation. 110 * Convert a base64 string into raw byte array representation.
120 */ 111 */
121_TYPE( int ) 112_TYPE( int )
122t_fromb64(dst, src) 113t_fromb64(char *dst, const char *src)
123 char * dst;
124 const char * src;
125{ 114{
126 unsigned char *a; 115 unsigned char *a;
127 char *loc; 116 char *loc;
@@ -179,9 +168,7 @@ t_fromb64(dst, src)
179} 168}
180 169
181_TYPE( int ) 170_TYPE( int )
182t_cstrfromb64(dst, src) 171t_cstrfromb64(cstr *dst, const char *src)
183 cstr * dst;
184 const char * src;
185{ 172{
186 int len; 173 int len;
187 cstr_set_length(dst, (strlen(src) * 6 + 7) / 8); 174 cstr_set_length(dst, (strlen(src) * 6 + 7) / 8);
@@ -194,10 +181,7 @@ t_cstrfromb64(dst, src)
194 * Convert a raw byte string into a null-terminated base64 ASCII string. 181 * Convert a raw byte string into a null-terminated base64 ASCII string.
195 */ 182 */
196_TYPE( char * ) 183_TYPE( char * )
197t_tob64(dst, src, size) 184t_tob64(char *dst, const char *src, unsigned size)
198 char * dst;
199 const char * src;
200 unsigned size;
201{ 185{
202 int c, pos = size % 3; 186 int c, pos = size % 3;
203 unsigned char b0 = 0, b1 = 0, b2 = 0, notleading = 0; 187 unsigned char b0 = 0, b1 = 0, b2 = 0, notleading = 0;
@@ -248,10 +232,7 @@ t_tob64(dst, src, size)
248} 232}
249 233
250_TYPE( char * ) 234_TYPE( char * )
251t_tob64cstr(dst, src, sz) 235t_tob64cstr(cstr *dst, const char *src, unsigned int sz)
252 cstr * dst;
253 const char * src;
254 unsigned int sz;
255{ 236{
256 cstr_set_length(dst, (sz * 8 + 5) / 6 + 1); 237 cstr_set_length(dst, (sz * 8 + 5) / 6 + 1);
257 return t_tob64(dst->data, src, sz); 238 return t_tob64(dst->data, src, sz);