Browse Source

use `unsigned long` for the length of a string

Steffen Jaeckel 6 years ago
parent
commit
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{center}
 \begin{small}
 \begin{small}
 \begin{tabular}{|l|l|l|}
 \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\_EOL      & -                      & End of SSH data sequence. \\
 \hline LTC\_SSHDATA\_BYTE     & \texttt{unsigned char} & \texttt{byte} type \\
 \hline LTC\_SSHDATA\_BYTE     & \texttt{unsigned char} & \texttt{byte} type \\
 \hline LTC\_SSHDATA\_BOOLEAN  & \texttt{unsigned char} & \texttt{boolean} 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.
 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)},
 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}
 \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.
 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*)},
 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}
 \chapter{Miscellaneous}
 \mysection{Base64 Encoding and Decoding}
 \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);
 int ecc_import_subject_public_key_info(const unsigned char *in, unsigned long inlen, ecc_key *key);
 
 
 #ifdef LTC_SSH
 #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
 #endif
 
 
 /* low level functions */
 /* 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
   Decode a SSH sequence using a VA list
   @param in     The input buffer
   @param in     The input buffer
   @param inlen  [in/out] The length of the input buffer and on output the amount of decoded data
   @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
   @return CRYPT_OK on success
 */
 */
 int ssh_decode_sequence_multi(const unsigned char *in, unsigned long *inlen, ...)
 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;
    char          *sdata;
    ulong32       *u32data;
    ulong32       *u32data;
    ulong64       *u64data;
    ulong64       *u64data;
-   ulong32       *bufsize;
+   unsigned long *bufsize;
    ulong32       size;
    ulong32       size;
    unsigned long remaining;
    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_STRING:
          case LTC_SSHDATA_NAMELIST:
          case LTC_SSHDATA_NAMELIST:
             sdata = vdata;
             sdata = vdata;
-            bufsize = va_arg(args, ulong32*);
+            bufsize = va_arg(args, unsigned long*);
             if (bufsize == NULL) {
             if (bufsize == NULL) {
                err = CRYPT_INVALID_ARG;
                err = CRYPT_INVALID_ARG;
                goto error;
                goto error;

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

@@ -20,7 +20,7 @@
   Encode a SSH sequence using a VA list
   Encode a SSH sequence using a VA list
   @param out    [out] Destination for data
   @param out    [out] Destination for data
   @param outlen [in/out] Length of buffer and resulting length of output
   @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
   @return CRYPT_OK on success
 */
 */
 int ssh_encode_sequence_multi(unsigned char *out, unsigned long *outlen, ...)
 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_STRING:
          case LTC_SSHDATA_NAMELIST:
          case LTC_SSHDATA_NAMELIST:
             LTC_UNUSED_PARAM( va_arg(args, char*) );
             LTC_UNUSED_PARAM( va_arg(args, char*) );
-            size += va_arg(args, ulong32);
+            size += va_arg(args, unsigned long);
             size += 4;
             size += 4;
             break;
             break;
          case LTC_SSHDATA_MPINT:
          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_STRING:
          case LTC_SSHDATA_NAMELIST:
          case LTC_SSHDATA_NAMELIST:
             sdata = va_arg(args, char*);
             sdata = va_arg(args, char*);
-            size = va_arg(args, ulong32);
+            size = va_arg(args, unsigned long);
             STORE32H(size, out);
             STORE32H(size, out);
             out += 4;
             out += 4;
             XMEMCPY(out, sdata, size);
             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
 #ifdef LTC_SSH
    else if (sigformat == LTC_ECCSIG_RFC5656) {
    else if (sigformat == LTC_ECCSIG_RFC5656) {
       char name[64], name2[64];
       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 */
       /* Decode as SSH data sequence, per RFC4251 */
       if ((err = ssh_decode_sequence_multi(sig, &siglen,
       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) {
    else if (sigformat == LTC_ECCSIG_RFC5656) {
       /* Get identifier string */
       /* Get identifier string */
       char name[64];
       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; }
       if ((err = ecc_ssh_ecdsa_encode_name(name, &namelen, key)) != CRYPT_OK) { goto errnokey; }
 
 
       /* Store as SSH data sequence, per RFC4251 */
       /* 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
   @param key       A public or private ECC key
   @return CRYPT_OK if successful
   @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];
    char oidstr[64];
    unsigned long oidlen = sizeof(oidstr);
    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
 #ifdef LTC_SSH
    else if (sigformat == LTC_ECCSIG_RFC5656) {
    else if (sigformat == LTC_ECCSIG_RFC5656) {
       char name[64], name2[64];
       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 */
       /* Decode as SSH data sequence, per RFC4251 */
       if ((err = ssh_decode_sequence_multi(sig, &siglen,
       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 char buffer[BUFSIZE];
    unsigned long buflen;
    unsigned long buflen;
-   ulong32 len;
+   unsigned long len;
    void *v, *zero;
    void *v, *zero;
    int err;
    int err;
 
 
@@ -200,7 +200,7 @@ static int _ssh_decoding_test(void)
 {
 {
    char strbuf[BUFSIZE];
    char strbuf[BUFSIZE];
    void *u, *v;
    void *u, *v;
-   ulong32 size;
+   unsigned long size;
    ulong32 tmp32;
    ulong32 tmp32;
    ulong64 tmp64;
    ulong64 tmp64;
    unsigned char tmp8;
    unsigned char tmp8;