Răsfoiți Sursa

use `unsigned long` for the length of a string

Steffen Jaeckel 6 ani în urmă
părinte
comite
9b6bf32f88

+ 5 - 3
doc/crypt.tex

@@ -7247,7 +7247,7 @@ The following enum is used to indicate a specific SSH data type
 \begin{center}
 \begin{small}
 \begin{tabular}{|l|l|l|}
-\hline \textbf{Definition}    & \textbf{arg data Type}      & \textbf{SSH Type} \\
+\hline \textbf{Definition}    & \textbf{arg data Type} & \textbf{SSH Type} \\
 \hline LTC\_SSHDATA\_EOL      & -                      & End of SSH data sequence. \\
 \hline LTC\_SSHDATA\_BYTE     & \texttt{unsigned char} & \texttt{byte} type \\
 \hline LTC\_SSHDATA\_BOOLEAN  & \texttt{unsigned char} & \texttt{boolean} type \\
@@ -7284,7 +7284,8 @@ on function invocation to the length of the destination buffer
 and after returning it will be filled with the number of octets written to the buffer.
 
 The encoding function \texttt{ssh\_encode\_sequence\_multi()} expects its items to be a pair of \texttt{(type, data)},
-except for the \texttt{string} resp. \texttt{name-list} type, which expects the triple \texttt{(type, data, size)}.
+except for the \texttt{string} resp. \texttt{name-list} type, which expects the triple \texttt{(type, data, size)}
+with \texttt{size} being of type \texttt{unsigned long}.
 
 
 \begin{verbatim}
@@ -7296,7 +7297,8 @@ on function invocation to the length of the sequence
 and after returning it will be filled with the decoded number of octets.
 
 The decoding function \texttt{ssh\_decode\_sequence\_multi()} expects its items to be a pair of \texttt{(type, data*)},
-except for the \texttt{string} resp. \texttt{name-list} type, which expects the triple \texttt{(type, data, size*)}.
+except for the \texttt{string} resp. \texttt{name-list} type, which expects the triple \texttt{(type, data, size*)}
+with \texttt{size*} being of type \texttt{unsigned long*}.
 
 \chapter{Miscellaneous}
 \mysection{Base64 Encoding and Decoding}

+ 1 - 1
src/headers/tomcrypt_private.h

@@ -240,7 +240,7 @@ int ecc_set_curve_by_size(int size, ecc_key *key);
 int ecc_import_subject_public_key_info(const unsigned char *in, unsigned long inlen, ecc_key *key);
 
 #ifdef LTC_SSH
-int ecc_ssh_ecdsa_encode_name(char *buffer, ulong32 *buflen, const ecc_key *key);
+int ecc_ssh_ecdsa_encode_name(char *buffer, unsigned long *buflen, const ecc_key *key);
 #endif
 
 /* low level functions */

+ 3 - 3
src/misc/ssh/ssh_decode_sequence_multi.c

@@ -20,7 +20,7 @@
   Decode a SSH sequence using a VA list
   @param in     The input buffer
   @param inlen  [in/out] The length of the input buffer and on output the amount of decoded data
-  @remark <...> is of the form <type, data*> (int, <unsigned char*,ulong32*,ulong64*>) except for string&name-list <type, data, size*> (int, void*, ulong32*)
+  @remark <...> is of the form <type, data*> (int, <unsigned char*,ulong32*,ulong64*>) except for string&name-list <type, data, size*> (int, void*, unsigned long*)
   @return CRYPT_OK on success
 */
 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, ...
    char          *sdata;
    ulong32       *u32data;
    ulong64       *u64data;
-   ulong32       *bufsize;
+   unsigned long *bufsize;
    ulong32       size;
    unsigned long remaining;
 
@@ -124,7 +124,7 @@ int ssh_decode_sequence_multi(const unsigned char *in, unsigned long *inlen, ...
          case LTC_SSHDATA_STRING:
          case LTC_SSHDATA_NAMELIST:
             sdata = vdata;
-            bufsize = va_arg(args, ulong32*);
+            bufsize = va_arg(args, unsigned long*);
             if (bufsize == NULL) {
                err = CRYPT_INVALID_ARG;
                goto error;

+ 3 - 3
src/misc/ssh/ssh_encode_sequence_multi.c

@@ -20,7 +20,7 @@
   Encode a SSH sequence using a VA list
   @param out    [out] Destination for data
   @param outlen [in/out] Length of buffer and resulting length of output
-  @remark <...> is of the form <type, data> (int, <int,ulong32,ulong64>) except for string&name-list <type, data, size> (int, void*, ulong32)
+  @remark <...> is of the form <type, data> (int, <int,ulong32,ulong64>) except for string&name-list <type, data, size> (int, void*, unsigned long)
   @return CRYPT_OK on success
 */
 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, ...)
          case LTC_SSHDATA_STRING:
          case LTC_SSHDATA_NAMELIST:
             LTC_UNUSED_PARAM( va_arg(args, char*) );
-            size += va_arg(args, ulong32);
+            size += va_arg(args, unsigned long);
             size += 4;
             break;
          case LTC_SSHDATA_MPINT:
@@ -118,7 +118,7 @@ int ssh_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...)
          case LTC_SSHDATA_STRING:
          case LTC_SSHDATA_NAMELIST:
             sdata = va_arg(args, char*);
-            size = va_arg(args, ulong32);
+            size = va_arg(args, unsigned long);
             STORE32H(size, out);
             out += 4;
             XMEMCPY(out, sdata, size);

+ 2 - 2
src/pk/ecc/ecc_recover_key.c

@@ -114,8 +114,8 @@ int ecc_recover_key(const unsigned char *sig,  unsigned long siglen,
 #ifdef LTC_SSH
    else if (sigformat == LTC_ECCSIG_RFC5656) {
       char name[64], name2[64];
-      ulong32 namelen = sizeof(name);
-      ulong32 name2len = sizeof(name2);
+      unsigned long namelen = sizeof(name);
+      unsigned long name2len = sizeof(name2);
 
       /* Decode as SSH data sequence, per RFC4251 */
       if ((err = ssh_decode_sequence_multi(sig, &siglen,

+ 1 - 1
src/pk/ecc/ecc_sign_hash.c

@@ -159,7 +159,7 @@ int ecc_sign_hash_ex(const unsigned char *in,  unsigned long inlen,
    else if (sigformat == LTC_ECCSIG_RFC5656) {
       /* Get identifier string */
       char name[64];
-      ulong32 namelen = sizeof(name);
+      unsigned long namelen = sizeof(name);
       if ((err = ecc_ssh_ecdsa_encode_name(name, &namelen, key)) != CRYPT_OK) { goto errnokey; }
 
       /* Store as SSH data sequence, per RFC4251 */

+ 1 - 1
src/pk/ecc/ecc_ssh_ecdsa_encode_name.c

@@ -21,7 +21,7 @@
   @param key       A public or private ECC key
   @return CRYPT_OK if successful
 */
-int ecc_ssh_ecdsa_encode_name(char *buffer, ulong32 *buflen, const ecc_key *key)
+int ecc_ssh_ecdsa_encode_name(char *buffer, unsigned long *buflen, const ecc_key *key)
 {
    char oidstr[64];
    unsigned long oidlen = sizeof(oidstr);

+ 2 - 2
src/pk/ecc/ecc_verify_hash.c

@@ -100,8 +100,8 @@ int ecc_verify_hash_ex(const unsigned char *sig,  unsigned long siglen,
 #ifdef LTC_SSH
    else if (sigformat == LTC_ECCSIG_RFC5656) {
       char name[64], name2[64];
-      ulong32 namelen = sizeof(name);
-      ulong32 name2len = sizeof(name2);
+      unsigned long namelen = sizeof(name);
+      unsigned long name2len = sizeof(name2);
 
       /* Decode as SSH data sequence, per RFC4251 */
       if ((err = ssh_decode_sequence_multi(sig, &siglen,

+ 2 - 2
tests/ssh_test.c

@@ -61,7 +61,7 @@ static int _ssh_encoding_test(void)
 {
    unsigned char buffer[BUFSIZE];
    unsigned long buflen;
-   ulong32 len;
+   unsigned long len;
    void *v, *zero;
    int err;
 
@@ -200,7 +200,7 @@ static int _ssh_decoding_test(void)
 {
    char strbuf[BUFSIZE];
    void *u, *v;
-   ulong32 size;
+   unsigned long size;
    ulong32 tmp32;
    ulong64 tmp64;
    unsigned char tmp8;