Browse Source

generalize `caps` argument of `base16_encode()`

probably we want to add more options in the future

I could think of support for some options of `xxd` resp. `hexdump`
Steffen Jaeckel 7 years ago
parent
commit
06c0606da2
3 changed files with 6 additions and 6 deletions
  1. 2 2
      doc/crypt.tex
  2. 1 1
      src/headers/tomcrypt_misc.h
  3. 3 3
      src/misc/base16/base16_encode.c

+ 2 - 2
doc/crypt.tex

@@ -6710,12 +6710,12 @@ To encode a binary string in base16 call:
 \begin{verbatim}
 int base16_encode(const unsigned char *in,  unsigned long  inlen,
                                  char *out, unsigned long *outlen,
-                                 int  caps);
+                        unsigned int   options);
 \end{verbatim}
 
 Where \textit{in} is the binary string,
 \textit{out} is where the ASCII output is placed
-and \textit{caps} is either $0$ to use lower-letter \textit{a..f} or else to use caps \textit{A..F}.
+and \textit{options} is either $0$ to use lower-letter \textit{a..f} or else to use caps \textit{A..F}.
 
 To decode a base16 string call:
 

+ 1 - 1
src/headers/tomcrypt_misc.h

@@ -54,7 +54,7 @@ int base32_decode(const          char *in,  unsigned long inlen,
 #ifdef LTC_BASE16
 int base16_encode(const unsigned char *in,  unsigned long  inlen,
                                  char *out, unsigned long *outlen,
-                                 int  caps);
+                        unsigned int   options);
 int base16_decode(const          char *in,  unsigned long  inlen,
                         unsigned char *out, unsigned long *outlen);
 #endif

+ 3 - 3
src/misc/base16/base16_encode.c

@@ -22,12 +22,12 @@
    @param inlen    The length of the input buffer
    @param out      [out] The destination of the Base16 encoded data
    @param outlen   [in/out] The max size and resulting size of the encoded data
-   @param caps     Output 'a-f' on 0 and 'A-F' otherwise.
+   @param options  Output 'a-f' on 0 and 'A-F' otherwise.
    @return CRYPT_OK if successful
 */
 int base16_encode(const unsigned char *in,  unsigned long  inlen,
                                  char *out, unsigned long *outlen,
-                                  int  caps)
+                        unsigned int   options)
 {
    unsigned long i, x;
    const char *alphabet;
@@ -52,7 +52,7 @@ int base16_encode(const unsigned char *in,  unsigned long  inlen,
    x--;
    *outlen = x; /* returning the length without terminating NUL */
 
-   if (caps == 0) alphabet = alphabets[0];
+   if (options == 0) alphabet = alphabets[0];
    else alphabet = alphabets[1];
 
    for (i = 0; i < x; i += 2) {