소스 검색

Merge branch 'streams-make_state_names_consistent' into develop

This fixes #427
Steffen Jaeckel 7 년 전
부모
커밋
c9c3c42739
9개의 변경된 파일149개의 추가작업 그리고 147개의 파일을 삭제
  1. 1 1
      demos/ltcrypt.c
  2. 30 30
      demos/tv_gen.c
  3. 6 6
      doc/crypt.tex
  4. 5 5
      src/headers/tomcrypt_cipher.h
  5. 78 78
      src/stream/sosemanuk/sosemanuk.c
  6. 14 14
      src/stream/sosemanuk/sosemanuk_test.c
  7. 1 1
      tests/der_test.c
  8. 4 4
      tests/ecc_test.c
  9. 10 8
      tests/no_prng.c

+ 1 - 1
demos/ltcrypt.c

@@ -18,7 +18,7 @@
 
 #include <tomcrypt.h>
 
-int usage(char *name)
+static int NORETURN usage(char *name)
 {
    int x;
 

+ 30 - 30
demos/tv_gen.c

@@ -8,7 +8,7 @@
  */
 #include "tomcrypt_private.h"
 
-void hash_gen(void)
+static void hash_gen(void)
 {
    unsigned char md[MAXBLOCKSIZE], *buf;
    unsigned long outlen, x, y, z;
@@ -49,7 +49,7 @@ void hash_gen(void)
    fclose(out);
 }
 
-void cipher_gen(void)
+static void cipher_gen(void)
 {
    unsigned char *key, pt[MAXBLOCKSIZE];
    unsigned long x, y, z, w;
@@ -124,7 +124,7 @@ void cipher_gen(void)
   fclose(out);
 }
 
-void hmac_gen(void)
+static void hmac_gen(void)
 {
    unsigned char key[MAXBLOCKSIZE], output[MAXBLOCKSIZE], *input;
    int x, y, z, err;
@@ -176,9 +176,9 @@ void hmac_gen(void)
    fclose(out);
 }
 
-void omac_gen(void)
-{
 #ifdef LTC_OMAC
+static void omac_gen(void)
+{
    unsigned char key[MAXBLOCKSIZE], output[MAXBLOCKSIZE], input[MAXBLOCKSIZE*2+2];
    int err, x, y, z, kl;
    FILE *out;
@@ -234,12 +234,12 @@ void omac_gen(void)
       fprintf(out, "\n");
    }
    fclose(out);
-#endif
 }
+#endif
 
-void pmac_gen(void)
-{
 #ifdef LTC_PMAC
+static void pmac_gen(void)
+{
    unsigned char key[MAXBLOCKSIZE], output[MAXBLOCKSIZE], input[MAXBLOCKSIZE*2+2];
    int err, x, y, z, kl;
    FILE *out;
@@ -295,12 +295,12 @@ void pmac_gen(void)
       fprintf(out, "\n");
    }
    fclose(out);
-#endif
 }
+#endif
 
-void eax_gen(void)
-{
 #ifdef LTC_EAX_MODE
+static void eax_gen(void)
+{
    int err, kl, x, y1, z;
    FILE *out;
    unsigned char key[MAXBLOCKSIZE], nonce[MAXBLOCKSIZE*2], header[MAXBLOCKSIZE*2],
@@ -361,12 +361,12 @@ void eax_gen(void)
       fprintf(out, "\n");
    }
    fclose(out);
-#endif
 }
+#endif
 
-void ocb_gen(void)
-{
 #ifdef LTC_OCB_MODE
+static void ocb_gen(void)
+{
    int err, kl, x, y1, z;
    FILE *out;
    unsigned char key[MAXBLOCKSIZE], nonce[MAXBLOCKSIZE*2],
@@ -430,12 +430,12 @@ void ocb_gen(void)
       fprintf(out, "\n");
    }
    fclose(out);
-#endif
 }
+#endif
 
-void ocb3_gen(void)
-{
 #ifdef LTC_OCB3_MODE
+static void ocb3_gen(void)
+{
    int err, kl, x, y1, z, noncelen;
    FILE *out;
    unsigned char key[MAXBLOCKSIZE], nonce[MAXBLOCKSIZE*2],
@@ -500,12 +500,12 @@ void ocb3_gen(void)
       fprintf(out, "\n");
    }
    fclose(out);
-#endif
 }
+#endif
 
-void ccm_gen(void)
-{
 #ifdef LTC_CCM_MODE
+static void ccm_gen(void)
+{
    int err, kl, x, y1, z;
    FILE *out;
    unsigned char key[MAXBLOCKSIZE], nonce[MAXBLOCKSIZE*2],
@@ -569,12 +569,12 @@ void ccm_gen(void)
       fprintf(out, "\n");
    }
    fclose(out);
-#endif
 }
+#endif
 
-void gcm_gen(void)
-{
 #ifdef LTC_GCM_MODE
+static void gcm_gen(void)
+{
    int err, kl, x, y1, z;
    FILE *out;
    unsigned char key[MAXBLOCKSIZE], plaintext[MAXBLOCKSIZE*2], tag[MAXBLOCKSIZE];
@@ -632,10 +632,10 @@ void gcm_gen(void)
       fprintf(out, "\n");
    }
    fclose(out);
-#endif
 }
+#endif
 
-void base64_gen(void)
+static void base64_gen(void)
 {
    FILE *out;
    unsigned char src[32], ch;
@@ -655,11 +655,11 @@ void base64_gen(void)
    fclose(out);
 }
 
-void math_gen(void)
+static void math_gen(void)
 {
 }
 
-void ecc_gen(void)
+static void ecc_gen(void)
 {
    FILE         *out;
    unsigned char str[512];
@@ -701,9 +701,9 @@ void ecc_gen(void)
    fclose(out);
 }
 
-void lrw_gen(void)
-{
 #ifdef LTC_LRW_MODE
+static void lrw_gen(void)
+{
    FILE *out;
    unsigned char tweak[16], key[16], iv[16], buf[1024];
    int x, y, err;
@@ -765,8 +765,8 @@ void lrw_gen(void)
        lrw_done(&lrw);
    }
    fclose(out);
-#endif
 }
+#endif
 
 int main(void)
 {

+ 6 - 6
doc/crypt.tex

@@ -1397,30 +1397,30 @@ information.
 
 Initialize by creating a Sosemanuk state and provide a 128- to 256-bit key to \textit{sosemanuk\_setup()}.
 \begin{verbatim}
-sosemanuk_state ss;
-err = sosemanuk_setup(&ss, key, keylen);
+sosemanuk_state st;
+err = sosemanuk_setup(&st, key, keylen);
 \end{verbatim}
 
 Finish initializing with an iv of up to 128 bits.
 \begin{verbatim}
-err = sosemanuk_setiv(&ss, iv, ivlen);
+err = sosemanuk_setiv(&st, iv, ivlen);
 \end{verbatim}
 
 For the actual encryption or decryption, call:
 \begin{verbatim}
-err = sosemanuk_crypt(&ss, in, inlen, out);
+err = sosemanuk_crypt(&st, in, inlen, out);
 \end{verbatim}
 
 If you just want a random stream of bytes initialize the cipher with a truly random
 \textit{key} (256 bits) and a truly random \textit{iv} (128 bits). After that you can
 get a stream of pseudo--random bytes via:
 \begin{verbatim}
-err = sosemanuk_keystream(&ss, out, outlen);
+err = sosemanuk_keystream(&st, out, outlen);
 \end{verbatim}
 
 When finished you should wipe the key by running \textit{sosemanuk\_done()}.
 \begin{verbatim}
-err = sosemanuk_done(&ss);
+err = sosemanuk_done(&st);
 \end{verbatim}
 
 To do multiple encryptions and decryptions with the same key, you will want to set the iv but

+ 5 - 5
src/headers/tomcrypt_cipher.h

@@ -1055,11 +1055,11 @@ typedef struct {
     unsigned ptr;
 } sosemanuk_state;
 
-int sosemanuk_setup(sosemanuk_state *ss, const unsigned char *key, unsigned long keylen);
-int sosemanuk_setiv(sosemanuk_state *ss, const unsigned char *iv, unsigned long ivlen);
-int sosemanuk_crypt(sosemanuk_state *ss, const unsigned char *in, unsigned long inlen, unsigned char *out);
-int sosemanuk_keystream(sosemanuk_state *ss, unsigned char *out, unsigned long outlen);
-int sosemanuk_done(sosemanuk_state *ss);
+int sosemanuk_setup(sosemanuk_state *st, const unsigned char *key, unsigned long keylen);
+int sosemanuk_setiv(sosemanuk_state *st, const unsigned char *iv, unsigned long ivlen);
+int sosemanuk_crypt(sosemanuk_state *st, const unsigned char *in, unsigned long inlen, unsigned char *out);
+int sosemanuk_keystream(sosemanuk_state *st, unsigned char *out, unsigned long outlen);
+int sosemanuk_done(sosemanuk_state *st);
 int sosemanuk_test(void);
 
 #endif /* LTC_SOSEMANUK */

+ 78 - 78
src/stream/sosemanuk/sosemanuk.c

@@ -196,12 +196,12 @@
 /*
  * Initialize Sosemanuk's state by providing a key. The key is an array of
  * 1 to 32 bytes.
- * @param ss       The Sosemanuk state
+ * @param st       The Sosemanuk state
  * @param key      Key
  * @param keylen   Length of key in bytes
  * @return CRYPT_OK on success
  */
-int sosemanuk_setup(sosemanuk_state *ss, const unsigned char *key, unsigned long keylen)
+int sosemanuk_setup(sosemanuk_state *st, const unsigned char *key, unsigned long keylen)
 {
     /*
      * This key schedule is actually a truncated Serpent key schedule.
@@ -216,10 +216,10 @@ int sosemanuk_setup(sosemanuk_state *ss, const unsigned char *key, unsigned long
         r2 = w ## o2; \
         r3 = w ## o3; \
         S(r0, r1, r2, r3, r4); \
-        ss->kc[i ++] = r ## d0; \
-        ss->kc[i ++] = r ## d1; \
-        ss->kc[i ++] = r ## d2; \
-        ss->kc[i ++] = r ## d3; \
+        st->kc[i ++] = r ## d0; \
+        st->kc[i ++] = r ## d1; \
+        st->kc[i ++] = r ## d2; \
+        st->kc[i ++] = r ## d3; \
     } while (0)
 
 #define SKS0    SKS(S0, 4, 5, 6, 7, 1, 4, 2, 0)
@@ -255,7 +255,7 @@ int sosemanuk_setup(sosemanuk_state *ss, const unsigned char *key, unsigned long
     ulong32 w0, w1, w2, w3, w4, w5, w6, w7;
     int i = 0;
 
-   LTC_ARGCHK(ss  != NULL);
+   LTC_ARGCHK(st  != NULL);
    LTC_ARGCHK(key != NULL);
    LTC_ARGCHK(keylen > 0 && keylen <= 32);
 
@@ -329,22 +329,22 @@ int sosemanuk_setup(sosemanuk_state *ss, const unsigned char *key, unsigned long
  * encryptions/decryptions are to be performed with the same key and
  * sosemanuk_done() has not been called, only sosemanuk_setiv() need be called
  * to set the state.
- * @param ss       The Sosemanuk state
+ * @param st       The Sosemanuk state
  * @param iv       Initialization vector
  * @param ivlen    Length of iv in bytes
  * @return CRYPT_OK on success
  */
-int sosemanuk_setiv(sosemanuk_state *ss, const unsigned char *iv, unsigned long ivlen)
+int sosemanuk_setiv(sosemanuk_state *st, const unsigned char *iv, unsigned long ivlen)
 {
 
     /*
      * The Serpent key addition step.
      */
 #define KA(zc, x0, x1, x2, x3)  do { \
-        x0 ^= ss->kc[(zc)]; \
-        x1 ^= ss->kc[(zc) + 1]; \
-        x2 ^= ss->kc[(zc) + 2]; \
-        x3 ^= ss->kc[(zc) + 3]; \
+        x0 ^= st->kc[(zc)]; \
+        x1 ^= st->kc[(zc) + 1]; \
+        x2 ^= st->kc[(zc) + 2]; \
+        x3 ^= st->kc[(zc) + 3]; \
     } while (0)
 
     /*
@@ -374,7 +374,7 @@ int sosemanuk_setiv(sosemanuk_state *ss, const unsigned char *iv, unsigned long
     ulong32 r0, r1, r2, r3, r4;
     unsigned char ivtmp[16] = {0};
 
-    LTC_ARGCHK(ss != NULL);
+    LTC_ARGCHK(st != NULL);
     LTC_ARGCHK(ivlen <= 16);
     LTC_ARGCHK(iv != NULL || ivlen == 0);
 
@@ -404,10 +404,10 @@ int sosemanuk_setiv(sosemanuk_state *ss, const unsigned char *iv, unsigned long
     FSS(36, S1, 1, 3, 2, 4, 0, 2, 1, 4, 3);
     FSS(40, S2, 2, 1, 4, 3, 0, 4, 3, 1, 0);
     FSS(44, S3, 4, 3, 1, 0, 2, 3, 1, 0, 2);
-    ss->s09 = r3;
-    ss->s08 = r1;
-    ss->s07 = r0;
-    ss->s06 = r2;
+    st->s09 = r3;
+    st->s08 = r1;
+    st->s07 = r0;
+    st->s06 = r2;
 
     FSS(48, S4, 3, 1, 0, 2, 4, 1, 4, 3, 2);
     FSS(52, S5, 1, 4, 3, 2, 0, 4, 2, 1, 3);
@@ -415,10 +415,10 @@ int sosemanuk_setiv(sosemanuk_state *ss, const unsigned char *iv, unsigned long
     FSS(60, S7, 4, 2, 0, 1, 3, 3, 1, 2, 4);
     FSS(64, S0, 3, 1, 2, 4, 0, 1, 0, 2, 3);
     FSS(68, S1, 1, 0, 2, 3, 4, 2, 1, 3, 0);
-    ss->r1  = r2;
-    ss->s04 = r1;
-    ss->r2  = r3;
-    ss->s05 = r0;
+    st->r1  = r2;
+    st->s04 = r1;
+    st->r2  = r3;
+    st->s05 = r0;
 
     FSS(72, S2, 2, 1, 3, 0, 4, 3, 0, 1, 4);
     FSS(76, S3, 3, 0, 1, 4, 2, 0, 1, 4, 2);
@@ -426,12 +426,12 @@ int sosemanuk_setiv(sosemanuk_state *ss, const unsigned char *iv, unsigned long
     FSS(84, S5, 1, 3, 0, 2, 4, 3, 2, 1, 0);
     FSS(88, S6, 3, 2, 1, 0, 4, 3, 2, 4, 1);
     FSF(92, S7, 3, 2, 4, 1, 0, 0, 1, 2, 3);
-    ss->s03 = r0;
-    ss->s02 = r1;
-    ss->s01 = r2;
-    ss->s00 = r3;
+    st->s03 = r0;
+    st->s02 = r1;
+    st->s01 = r2;
+    st->s00 = r3;
 
-    ss->ptr = sizeof(ss->buf);
+    st->ptr = sizeof(st->buf);
 
 #undef KA
 #undef FSS
@@ -585,7 +585,7 @@ static const ulong32 mul_ia[] = {
  * Compute the next block of bits of output stream. This is equivalent
  * to one full rotation of the shift register.
  */
-static LTC_INLINE void _sosemanuk_internal(sosemanuk_state *ss)
+static LTC_INLINE void _sosemanuk_internal(sosemanuk_state *st)
 {
     /*
      * MUL_A(x) computes alpha * x (in F_{2^32}).
@@ -656,24 +656,24 @@ static LTC_INLINE void _sosemanuk_internal(sosemanuk_state *ss)
      */
 #define SRD(S, x0, x1, x2, x3, ooff)   do { \
         S(u0, u1, u2, u3, u4); \
-        STORE32L(u ## x0 ^ v0, ss->buf + ooff); \
-        STORE32L(u ## x1 ^ v1, ss->buf + ooff +  4); \
-        STORE32L(u ## x2 ^ v2, ss->buf + ooff +  8); \
-        STORE32L(u ## x3 ^ v3, ss->buf + ooff + 12); \
+        STORE32L(u ## x0 ^ v0, st->buf + ooff); \
+        STORE32L(u ## x1 ^ v1, st->buf + ooff +  4); \
+        STORE32L(u ## x2 ^ v2, st->buf + ooff +  8); \
+        STORE32L(u ## x3 ^ v3, st->buf + ooff + 12); \
     } while (0)
 
-    ulong32 s00 = ss->s00;
-    ulong32 s01 = ss->s01;
-    ulong32 s02 = ss->s02;
-    ulong32 s03 = ss->s03;
-    ulong32 s04 = ss->s04;
-    ulong32 s05 = ss->s05;
-    ulong32 s06 = ss->s06;
-    ulong32 s07 = ss->s07;
-    ulong32 s08 = ss->s08;
-    ulong32 s09 = ss->s09;
-    ulong32 r1 = ss->r1;
-    ulong32 r2 = ss->r2;
+    ulong32 s00 = st->s00;
+    ulong32 s01 = st->s01;
+    ulong32 s02 = st->s02;
+    ulong32 s03 = st->s03;
+    ulong32 s04 = st->s04;
+    ulong32 s05 = st->s05;
+    ulong32 s06 = st->s06;
+    ulong32 s07 = st->s07;
+    ulong32 s08 = st->s08;
+    ulong32 s09 = st->s09;
+    ulong32 r1 = st->r1;
+    ulong32 r2 = st->r2;
     ulong32 u0, u1, u2, u3, u4;
     ulong32 v0, v1, v2, v3;
 
@@ -703,18 +703,18 @@ static LTC_INLINE void _sosemanuk_internal(sosemanuk_state *ss)
     STEP(09, 00, 01, 02, 03, 04, 05, 06, 07, 08, v3, u3);
     SRD(S2, 2, 3, 1, 4, 64);
 
-    ss->s00 = s00;
-    ss->s01 = s01;
-    ss->s02 = s02;
-    ss->s03 = s03;
-    ss->s04 = s04;
-    ss->s05 = s05;
-    ss->s06 = s06;
-    ss->s07 = s07;
-    ss->s08 = s08;
-    ss->s09 = s09;
-    ss->r1 = r1;
-    ss->r2 = r2;
+    st->s00 = s00;
+    st->s01 = s01;
+    st->s02 = s02;
+    st->s03 = s03;
+    st->s04 = s04;
+    st->s05 = s05;
+    st->s06 = s06;
+    st->s07 = s07;
+    st->s08 = s08;
+    st->s09 = s09;
+    st->r1 = r1;
+    st->r2 = r2;
 }
 
 /*
@@ -737,41 +737,41 @@ static LTC_INLINE void _xorbuf(const unsigned char *in1, const unsigned char *in
  * buffer, combined by XOR with the stream, and the result is written
  * in the "out" buffer. "in" and "out" must be either equal, or
  * reference distinct buffers (no partial overlap is allowed).
- * @param ss       The Sosemanuk state
+ * @param st       The Sosemanuk state
  * @param in       Data in
  * @param inlen    Length of data in bytes
  * @param out      Data out
  * @return CRYPT_OK on success
  */
-int sosemanuk_crypt(sosemanuk_state *ss,
+int sosemanuk_crypt(sosemanuk_state *st,
                         const unsigned char *in, unsigned long inlen, unsigned char *out)
 {
-    LTC_ARGCHK(ss  != NULL);
+    LTC_ARGCHK(st  != NULL);
     LTC_ARGCHK(in  != NULL);
     LTC_ARGCHK(out != NULL);
 
-    if (ss->ptr < (sizeof(ss->buf))) {
-        unsigned long rlen = (sizeof(ss->buf)) - ss->ptr;
+    if (st->ptr < (sizeof(st->buf))) {
+        unsigned long rlen = (sizeof(st->buf)) - st->ptr;
 
         if (rlen > inlen) {
             rlen = inlen;
         }
-        _xorbuf(ss->buf + ss->ptr, in, out, rlen);
+        _xorbuf(st->buf + st->ptr, in, out, rlen);
         in += rlen;
         out += rlen;
         inlen -= rlen;
-        ss->ptr += rlen;
+        st->ptr += rlen;
     }
     while (inlen > 0) {
-        _sosemanuk_internal(ss);
-        if (inlen >= sizeof(ss->buf)) {
-            _xorbuf(ss->buf, in, out, sizeof(ss->buf));
-            in += sizeof(ss->buf);
-            out += sizeof(ss->buf);
-            inlen -= sizeof(ss->buf);
+        _sosemanuk_internal(st);
+        if (inlen >= sizeof(st->buf)) {
+            _xorbuf(st->buf, in, out, sizeof(st->buf));
+            in += sizeof(st->buf);
+            out += sizeof(st->buf);
+            inlen -= sizeof(st->buf);
         } else {
-            _xorbuf(ss->buf, in, out, inlen);
-            ss->ptr = inlen;
+            _xorbuf(st->buf, in, out, inlen);
+            st->ptr = inlen;
             inlen = 0;
         }
     }
@@ -783,29 +783,29 @@ int sosemanuk_crypt(sosemanuk_state *ss,
 /*
  * Cipher operation, as a PRNG: the provided output buffer is filled with
  * pseudo-random bytes as output from the stream cipher.
- * @param ss       The Sosemanuk state
+ * @param st       The Sosemanuk state
  * @param out      Data out
  * @param outlen   Length of output in bytes
  * @return CRYPT_OK on success
  */
-int sosemanuk_keystream(sosemanuk_state *ss, unsigned char *out, unsigned long outlen)
+int sosemanuk_keystream(sosemanuk_state *st, unsigned char *out, unsigned long outlen)
 {
    if (outlen == 0) return CRYPT_OK; /* nothing to do */
    LTC_ARGCHK(out != NULL);
    XMEMSET(out, 0, outlen);
-   return sosemanuk_crypt(ss, out, outlen, out);
+   return sosemanuk_crypt(st, out, outlen, out);
 }
 
 
 /*
  * Terminate and clear Sosemanuk key context
- * @param ss      The Sosemanuk state
+ * @param st      The Sosemanuk state
  * @return CRYPT_OK on success
  */
-int sosemanuk_done(sosemanuk_state *ss)
+int sosemanuk_done(sosemanuk_state *st)
 {
-   LTC_ARGCHK(ss != NULL);
-   XMEMSET(ss, 0, sizeof(sosemanuk_state));
+   LTC_ARGCHK(st != NULL);
+   XMEMSET(st, 0, sizeof(sosemanuk_state));
    return CRYPT_OK;
 }
 

+ 14 - 14
src/stream/sosemanuk/sosemanuk_test.c

@@ -15,7 +15,7 @@ int sosemanuk_test(void)
 #ifndef LTC_TEST
    return CRYPT_NOP;
 #else
-   sosemanuk_state ss;
+   sosemanuk_state st;
    int err;
    unsigned char out[1000];
 
@@ -30,18 +30,18 @@ int sosemanuk_test(void)
        unsigned long len;
        len = strlen(pt);
        /* crypt piece by piece */
-       if ((err = sosemanuk_setup(&ss, k, sizeof(k)))                                != CRYPT_OK) return err;
-       if ((err = sosemanuk_setiv(&ss, n, sizeof(n)))                                != CRYPT_OK) return err;
-       if ((err = sosemanuk_crypt(&ss, (unsigned char*)pt,       5,       out))      != CRYPT_OK) return err;
-       if ((err = sosemanuk_crypt(&ss, (unsigned char*)pt +  5, 25,       out +  5)) != CRYPT_OK) return err;
-       if ((err = sosemanuk_crypt(&ss, (unsigned char*)pt + 30, 10,       out + 30)) != CRYPT_OK) return err;
-       if ((err = sosemanuk_crypt(&ss, (unsigned char*)pt + 40, len - 40, out + 40)) != CRYPT_OK) return err;
+       if ((err = sosemanuk_setup(&st, k, sizeof(k)))                                != CRYPT_OK) return err;
+       if ((err = sosemanuk_setiv(&st, n, sizeof(n)))                                != CRYPT_OK) return err;
+       if ((err = sosemanuk_crypt(&st, (unsigned char*)pt,       5,       out))      != CRYPT_OK) return err;
+       if ((err = sosemanuk_crypt(&st, (unsigned char*)pt +  5, 25,       out +  5)) != CRYPT_OK) return err;
+       if ((err = sosemanuk_crypt(&st, (unsigned char*)pt + 30, 10,       out + 30)) != CRYPT_OK) return err;
+       if ((err = sosemanuk_crypt(&st, (unsigned char*)pt + 40, len - 40, out + 40)) != CRYPT_OK) return err;
        if (compare_testvector(out, len, ct, sizeof(ct), "SOSEMANUK-TV1", 1))                      return CRYPT_FAIL_TESTVECTOR;
 
        /* crypt in one go - using sosemanuk_ivctr64() */
-       if ((err = sosemanuk_setup(&ss, k, sizeof(k)))                 != CRYPT_OK) return err;
-       if ((err = sosemanuk_setiv(&ss, n, sizeof(n)))                 != CRYPT_OK) return err;
-       if ((err = sosemanuk_crypt(&ss, (unsigned char*)pt, len, out)) != CRYPT_OK) return err;
+       if ((err = sosemanuk_setup(&st, k, sizeof(k)))                 != CRYPT_OK) return err;
+       if ((err = sosemanuk_setiv(&st, n, sizeof(n)))                 != CRYPT_OK) return err;
+       if ((err = sosemanuk_crypt(&st, (unsigned char*)pt, len, out)) != CRYPT_OK) return err;
        if (compare_testvector(out, len, ct, sizeof(ct), "SOSEMANUK-TV2", 1))       return CRYPT_FAIL_TESTVECTOR;
 
    }
@@ -66,10 +66,10 @@ int sosemanuk_test(void)
                                0x0F, 0x5A, 0x24, 0xAA, 0xFE, 0xC8, 0xE0, 0xC9, 0xF9, 0xD2, 0xCE, 0x48, 0xB2, 0xAD, 0xB0, 0xA3,
                                0x4D, 0x2E, 0x8C, 0x4E, 0x01, 0x61, 0x02, 0x60, 0x73, 0x68, 0xFF, 0xA4, 0x3A, 0x0F, 0x91, 0x55,
                                0x07, 0x06, 0xE3, 0x54, 0x8A, 0xD9, 0xE5, 0xEA, 0x15, 0xA5, 0x3E, 0xB6, 0xF0, 0xED, 0xE9, 0xDC };
-       if ((err = sosemanuk_setup(&ss, k3, sizeof(k3)))      != CRYPT_OK)     return err;
-       if ((err = sosemanuk_setiv(&ss, n3, sizeof(n3)))      != CRYPT_OK)     return err;
-       if ((err = sosemanuk_keystream(&ss, out, 64))         != CRYPT_OK)     return err;
-       if ((err = sosemanuk_done(&ss))                       != CRYPT_OK)     return err;
+       if ((err = sosemanuk_setup(&st, k3, sizeof(k3)))      != CRYPT_OK)     return err;
+       if ((err = sosemanuk_setiv(&st, n3, sizeof(n3)))      != CRYPT_OK)     return err;
+       if ((err = sosemanuk_keystream(&st, out, 64))         != CRYPT_OK)     return err;
+       if ((err = sosemanuk_done(&st))                       != CRYPT_OK)     return err;
        if (compare_testvector(out, 64, ct3, sizeof(ct3), "SOSEMANUK-TV3", 1)) return CRYPT_FAIL_TESTVECTOR;
    }
 

+ 1 - 1
tests/der_test.c

@@ -1301,7 +1301,7 @@ static void der_Xcode_test(void)
 }
 
 #ifdef LTC_TEST_READDIR
-int _der_decode_sequence_flexi(const void *in, unsigned long inlen, void* ctx)
+static int _der_decode_sequence_flexi(const void *in, unsigned long inlen, void* ctx)
 {
    ltc_asn1_list** list = ctx;
    if (der_decode_sequence_flexi(in, &inlen, list) == CRYPT_OK) {

+ 4 - 4
tests/ecc_test.c

@@ -209,7 +209,7 @@ done:
    return err;
 }
 
-int _ecc_old_api(void)
+static int _ecc_old_api(void)
 {
    unsigned char buf[4][4096], ch;
    unsigned long x, y, z, s;
@@ -350,7 +350,7 @@ int _ecc_old_api(void)
    return CRYPT_OK;
 }
 
-int _ecc_new_api(void)
+static int _ecc_new_api(void)
 {
    const char* names[] = {
 #ifdef LTC_ECC_SECP112R1
@@ -517,7 +517,7 @@ int _ecc_new_api(void)
    return CRYPT_OK;
 }
 
-int _ecc_key_cmp(const int should_type, const ecc_key *should, const ecc_key *is)
+static int _ecc_key_cmp(const int should_type, const ecc_key *should, const ecc_key *is)
 {
    if (should_type != is->type)                               return CRYPT_ERROR;
    if (should_type == PK_PRIVATE) {
@@ -536,7 +536,7 @@ int _ecc_key_cmp(const int should_type, const ecc_key *should, const ecc_key *is
    return CRYPT_OK;
 }
 
-int _ecc_import_export(void) {
+static int _ecc_import_export(void) {
    const ltc_ecc_curve *cu;
    ecc_key key, pri, pub;
    unsigned char out[300];

+ 10 - 8
tests/no_prng.c

@@ -6,7 +6,9 @@
  * The library is free for all purposes without any express
  * guarantee it works.
  */
+
 #include "tomcrypt.h"
+#include "tomcrypt_test.h"
 
 /**
   @file no_prng.c
@@ -29,7 +31,7 @@ typedef struct
   @param prng     [out] The PRNG state to initialize
   @return CRYPT_OK if successful
 */
-int no_prng_start(prng_state *prng)
+static int no_prng_start(prng_state *prng)
 {
    no_prng_desc_t *no_prng = (no_prng_desc_t*) prng;
    LTC_ARGCHK(no_prng != NULL);
@@ -47,7 +49,7 @@ int no_prng_start(prng_state *prng)
   @param prng     PRNG state to update
   @return CRYPT_OK if successful
 */
-int no_prng_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng)
+static int no_prng_add_entropy(const unsigned char *in, unsigned long inlen, prng_state *prng)
 {
    no_prng_desc_t *no_prng = (no_prng_desc_t*) prng;
    LTC_ARGCHK(no_prng != NULL);
@@ -68,7 +70,7 @@ int no_prng_add_entropy(const unsigned char *in, unsigned long inlen, prng_state
   @param prng   The PRNG to make active
   @return CRYPT_OK if successful
 */
-int no_prng_ready(prng_state *prng)
+static int no_prng_ready(prng_state *prng)
 {
     LTC_ARGCHK(prng != NULL);
 
@@ -82,7 +84,7 @@ int no_prng_ready(prng_state *prng)
   @param prng     The active PRNG to read from
   @return Number of octets read
 */
-unsigned long no_prng_read(unsigned char *out, unsigned long outlen, prng_state *prng)
+static unsigned long no_prng_read(unsigned char *out, unsigned long outlen, prng_state *prng)
 {
    no_prng_desc_t *no_prng = (no_prng_desc_t*) prng;
    LTC_ARGCHK(no_prng != NULL);
@@ -101,7 +103,7 @@ unsigned long no_prng_read(unsigned char *out, unsigned long outlen, prng_state
   @param prng   The PRNG to terminate
   @return CRYPT_OK if successful
 */
-int no_prng_done(prng_state *prng)
+static int no_prng_done(prng_state *prng)
 {
    LTC_UNUSED_PARAM(prng);
    return CRYPT_OK;
@@ -114,7 +116,7 @@ int no_prng_done(prng_state *prng)
   @param prng      The PRNG to export
   @return CRYPT_OK if successful
 */
-int no_prng_export(unsigned char *out, unsigned long *outlen, prng_state *prng)
+static int no_prng_export(unsigned char *out, unsigned long *outlen, prng_state *prng)
 {
    LTC_UNUSED_PARAM(out);
    LTC_UNUSED_PARAM(outlen);
@@ -129,7 +131,7 @@ int no_prng_export(unsigned char *out, unsigned long *outlen, prng_state *prng)
   @param prng     The PRNG to import
   @return CRYPT_OK if successful
 */
-int no_prng_import(const unsigned char *in, unsigned long inlen, prng_state *prng)
+static int no_prng_import(const unsigned char *in, unsigned long inlen, prng_state *prng)
 {
    LTC_UNUSED_PARAM(in);
    LTC_UNUSED_PARAM(inlen);
@@ -141,7 +143,7 @@ int no_prng_import(const unsigned char *in, unsigned long inlen, prng_state *prn
   PRNG self-test
   @return CRYPT_OK if successful, CRYPT_NOP if self-testing has been disabled
 */
-int no_prng_test(void)
+static int no_prng_test(void)
 {
    return CRYPT_OK;
 }