Skip to content

Commit 9b6bf32

Browse files
committed
use unsigned long for the length of a string
1 parent 27ec31d commit 9b6bf32

File tree

9 files changed

+20
-18
lines changed

9 files changed

+20
-18
lines changed

doc/crypt.tex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7247,7 +7247,7 @@ \subsection{Data types}
72477247
\begin{center}
72487248
\begin{small}
72497249
\begin{tabular}{|l|l|l|}
7250-
\hline \textbf{Definition} & \textbf{arg data Type} & \textbf{SSH Type} \\
7250+
\hline \textbf{Definition} & \textbf{arg data Type} & \textbf{SSH Type} \\
72517251
\hline LTC\_SSHDATA\_EOL & - & End of SSH data sequence. \\
72527252
\hline LTC\_SSHDATA\_BYTE & \texttt{unsigned char} & \texttt{byte} type \\
72537253
\hline LTC\_SSHDATA\_BOOLEAN & \texttt{unsigned char} & \texttt{boolean} type \\
@@ -7284,7 +7284,8 @@ \subsection{De- and Encoding with Multiple Argument Lists}
72847284
and after returning it will be filled with the number of octets written to the buffer.
72857285

72867286
The encoding function \texttt{ssh\_encode\_sequence\_multi()} expects its items to be a pair of \texttt{(type, data)},
7287-
except for the \texttt{string} resp. \texttt{name-list} type, which expects the triple \texttt{(type, data, size)}.
7287+
except for the \texttt{string} resp. \texttt{name-list} type, which expects the triple \texttt{(type, data, size)}
7288+
with \texttt{size} being of type \texttt{unsigned long}.
72887289

72897290

72907291
\begin{verbatim}
@@ -7296,7 +7297,8 @@ \subsection{De- and Encoding with Multiple Argument Lists}
72967297
and after returning it will be filled with the decoded number of octets.
72977298

72987299
The decoding function \texttt{ssh\_decode\_sequence\_multi()} expects its items to be a pair of \texttt{(type, data*)},
7299-
except for the \texttt{string} resp. \texttt{name-list} type, which expects the triple \texttt{(type, data, size*)}.
7300+
except for the \texttt{string} resp. \texttt{name-list} type, which expects the triple \texttt{(type, data, size*)}
7301+
with \texttt{size*} being of type \texttt{unsigned long*}.
73007302

73017303
\chapter{Miscellaneous}
73027304
\mysection{Base64 Encoding and Decoding}

src/headers/tomcrypt_private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ int ecc_set_curve_by_size(int size, ecc_key *key);
240240
int ecc_import_subject_public_key_info(const unsigned char *in, unsigned long inlen, ecc_key *key);
241241

242242
#ifdef LTC_SSH
243-
int ecc_ssh_ecdsa_encode_name(char *buffer, ulong32 *buflen, const ecc_key *key);
243+
int ecc_ssh_ecdsa_encode_name(char *buffer, unsigned long *buflen, const ecc_key *key);
244244
#endif
245245

246246
/* low level functions */

src/misc/ssh/ssh_decode_sequence_multi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
Decode a SSH sequence using a VA list
2121
@param in The input buffer
2222
@param inlen [in/out] The length of the input buffer and on output the amount of decoded data
23-
@remark <...> is of the form <type, data*> (int, <unsigned char*,ulong32*,ulong64*>) except for string&name-list <type, data, size*> (int, void*, ulong32*)
23+
@remark <...> is of the form <type, data*> (int, <unsigned char*,ulong32*,ulong64*>) except for string&name-list <type, data, size*> (int, void*, unsigned long*)
2424
@return CRYPT_OK on success
2525
*/
2626
int ssh_decode_sequence_multi(const unsigned char *in, unsigned long *inlen, ...)
@@ -33,7 +33,7 @@ int ssh_decode_sequence_multi(const unsigned char *in, unsigned long *inlen, ...
3333
char *sdata;
3434
ulong32 *u32data;
3535
ulong64 *u64data;
36-
ulong32 *bufsize;
36+
unsigned long *bufsize;
3737
ulong32 size;
3838
unsigned long remaining;
3939

@@ -124,7 +124,7 @@ int ssh_decode_sequence_multi(const unsigned char *in, unsigned long *inlen, ...
124124
case LTC_SSHDATA_STRING:
125125
case LTC_SSHDATA_NAMELIST:
126126
sdata = vdata;
127-
bufsize = va_arg(args, ulong32*);
127+
bufsize = va_arg(args, unsigned long*);
128128
if (bufsize == NULL) {
129129
err = CRYPT_INVALID_ARG;
130130
goto error;

src/misc/ssh/ssh_encode_sequence_multi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
Encode a SSH sequence using a VA list
2121
@param out [out] Destination for data
2222
@param outlen [in/out] Length of buffer and resulting length of output
23-
@remark <...> is of the form <type, data> (int, <int,ulong32,ulong64>) except for string&name-list <type, data, size> (int, void*, ulong32)
23+
@remark <...> is of the form <type, data> (int, <int,ulong32,ulong64>) except for string&name-list <type, data, size> (int, void*, unsigned long)
2424
@return CRYPT_OK on success
2525
*/
2626
int ssh_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...)
@@ -59,7 +59,7 @@ int ssh_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...)
5959
case LTC_SSHDATA_STRING:
6060
case LTC_SSHDATA_NAMELIST:
6161
LTC_UNUSED_PARAM( va_arg(args, char*) );
62-
size += va_arg(args, ulong32);
62+
size += va_arg(args, unsigned long);
6363
size += 4;
6464
break;
6565
case LTC_SSHDATA_MPINT:
@@ -118,7 +118,7 @@ int ssh_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...)
118118
case LTC_SSHDATA_STRING:
119119
case LTC_SSHDATA_NAMELIST:
120120
sdata = va_arg(args, char*);
121-
size = va_arg(args, ulong32);
121+
size = va_arg(args, unsigned long);
122122
STORE32H(size, out);
123123
out += 4;
124124
XMEMCPY(out, sdata, size);

src/pk/ecc/ecc_recover_key.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ int ecc_recover_key(const unsigned char *sig, unsigned long siglen,
114114
#ifdef LTC_SSH
115115
else if (sigformat == LTC_ECCSIG_RFC5656) {
116116
char name[64], name2[64];
117-
ulong32 namelen = sizeof(name);
118-
ulong32 name2len = sizeof(name2);
117+
unsigned long namelen = sizeof(name);
118+
unsigned long name2len = sizeof(name2);
119119

120120
/* Decode as SSH data sequence, per RFC4251 */
121121
if ((err = ssh_decode_sequence_multi(sig, &siglen,

src/pk/ecc/ecc_sign_hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ int ecc_sign_hash_ex(const unsigned char *in, unsigned long inlen,
159159
else if (sigformat == LTC_ECCSIG_RFC5656) {
160160
/* Get identifier string */
161161
char name[64];
162-
ulong32 namelen = sizeof(name);
162+
unsigned long namelen = sizeof(name);
163163
if ((err = ecc_ssh_ecdsa_encode_name(name, &namelen, key)) != CRYPT_OK) { goto errnokey; }
164164

165165
/* Store as SSH data sequence, per RFC4251 */

src/pk/ecc/ecc_ssh_ecdsa_encode_name.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
@param key A public or private ECC key
2222
@return CRYPT_OK if successful
2323
*/
24-
int ecc_ssh_ecdsa_encode_name(char *buffer, ulong32 *buflen, const ecc_key *key)
24+
int ecc_ssh_ecdsa_encode_name(char *buffer, unsigned long *buflen, const ecc_key *key)
2525
{
2626
char oidstr[64];
2727
unsigned long oidlen = sizeof(oidstr);

src/pk/ecc/ecc_verify_hash.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ int ecc_verify_hash_ex(const unsigned char *sig, unsigned long siglen,
100100
#ifdef LTC_SSH
101101
else if (sigformat == LTC_ECCSIG_RFC5656) {
102102
char name[64], name2[64];
103-
ulong32 namelen = sizeof(name);
104-
ulong32 name2len = sizeof(name2);
103+
unsigned long namelen = sizeof(name);
104+
unsigned long name2len = sizeof(name2);
105105

106106
/* Decode as SSH data sequence, per RFC4251 */
107107
if ((err = ssh_decode_sequence_multi(sig, &siglen,

tests/ssh_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static int _ssh_encoding_test(void)
6161
{
6262
unsigned char buffer[BUFSIZE];
6363
unsigned long buflen;
64-
ulong32 len;
64+
unsigned long len;
6565
void *v, *zero;
6666
int err;
6767

@@ -200,7 +200,7 @@ static int _ssh_decoding_test(void)
200200
{
201201
char strbuf[BUFSIZE];
202202
void *u, *v;
203-
ulong32 size;
203+
unsigned long size;
204204
ulong32 tmp32;
205205
ulong64 tmp64;
206206
unsigned char tmp8;

0 commit comments

Comments
 (0)