Skip to content

Commit c9c3c42

Browse files
committed
Merge branch 'streams-make_state_names_consistent' into develop
This fixes #427
2 parents b5009d7 + 380d1d2 commit c9c3c42

File tree

9 files changed

+149
-147
lines changed

9 files changed

+149
-147
lines changed

demos/ltcrypt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#include <tomcrypt.h>
2020

21-
int usage(char *name)
21+
static int NORETURN usage(char *name)
2222
{
2323
int x;
2424

demos/tv_gen.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
#include "tomcrypt_private.h"
1010

11-
void hash_gen(void)
11+
static void hash_gen(void)
1212
{
1313
unsigned char md[MAXBLOCKSIZE], *buf;
1414
unsigned long outlen, x, y, z;
@@ -49,7 +49,7 @@ void hash_gen(void)
4949
fclose(out);
5050
}
5151

52-
void cipher_gen(void)
52+
static void cipher_gen(void)
5353
{
5454
unsigned char *key, pt[MAXBLOCKSIZE];
5555
unsigned long x, y, z, w;
@@ -124,7 +124,7 @@ void cipher_gen(void)
124124
fclose(out);
125125
}
126126

127-
void hmac_gen(void)
127+
static void hmac_gen(void)
128128
{
129129
unsigned char key[MAXBLOCKSIZE], output[MAXBLOCKSIZE], *input;
130130
int x, y, z, err;
@@ -176,9 +176,9 @@ void hmac_gen(void)
176176
fclose(out);
177177
}
178178

179-
void omac_gen(void)
180-
{
181179
#ifdef LTC_OMAC
180+
static void omac_gen(void)
181+
{
182182
unsigned char key[MAXBLOCKSIZE], output[MAXBLOCKSIZE], input[MAXBLOCKSIZE*2+2];
183183
int err, x, y, z, kl;
184184
FILE *out;
@@ -234,12 +234,12 @@ void omac_gen(void)
234234
fprintf(out, "\n");
235235
}
236236
fclose(out);
237-
#endif
238237
}
238+
#endif
239239

240-
void pmac_gen(void)
241-
{
242240
#ifdef LTC_PMAC
241+
static void pmac_gen(void)
242+
{
243243
unsigned char key[MAXBLOCKSIZE], output[MAXBLOCKSIZE], input[MAXBLOCKSIZE*2+2];
244244
int err, x, y, z, kl;
245245
FILE *out;
@@ -295,12 +295,12 @@ void pmac_gen(void)
295295
fprintf(out, "\n");
296296
}
297297
fclose(out);
298-
#endif
299298
}
299+
#endif
300300

301-
void eax_gen(void)
302-
{
303301
#ifdef LTC_EAX_MODE
302+
static void eax_gen(void)
303+
{
304304
int err, kl, x, y1, z;
305305
FILE *out;
306306
unsigned char key[MAXBLOCKSIZE], nonce[MAXBLOCKSIZE*2], header[MAXBLOCKSIZE*2],
@@ -361,12 +361,12 @@ void eax_gen(void)
361361
fprintf(out, "\n");
362362
}
363363
fclose(out);
364-
#endif
365364
}
365+
#endif
366366

367-
void ocb_gen(void)
368-
{
369367
#ifdef LTC_OCB_MODE
368+
static void ocb_gen(void)
369+
{
370370
int err, kl, x, y1, z;
371371
FILE *out;
372372
unsigned char key[MAXBLOCKSIZE], nonce[MAXBLOCKSIZE*2],
@@ -430,12 +430,12 @@ void ocb_gen(void)
430430
fprintf(out, "\n");
431431
}
432432
fclose(out);
433-
#endif
434433
}
434+
#endif
435435

436-
void ocb3_gen(void)
437-
{
438436
#ifdef LTC_OCB3_MODE
437+
static void ocb3_gen(void)
438+
{
439439
int err, kl, x, y1, z, noncelen;
440440
FILE *out;
441441
unsigned char key[MAXBLOCKSIZE], nonce[MAXBLOCKSIZE*2],
@@ -500,12 +500,12 @@ void ocb3_gen(void)
500500
fprintf(out, "\n");
501501
}
502502
fclose(out);
503-
#endif
504503
}
504+
#endif
505505

506-
void ccm_gen(void)
507-
{
508506
#ifdef LTC_CCM_MODE
507+
static void ccm_gen(void)
508+
{
509509
int err, kl, x, y1, z;
510510
FILE *out;
511511
unsigned char key[MAXBLOCKSIZE], nonce[MAXBLOCKSIZE*2],
@@ -569,12 +569,12 @@ void ccm_gen(void)
569569
fprintf(out, "\n");
570570
}
571571
fclose(out);
572-
#endif
573572
}
573+
#endif
574574

575-
void gcm_gen(void)
576-
{
577575
#ifdef LTC_GCM_MODE
576+
static void gcm_gen(void)
577+
{
578578
int err, kl, x, y1, z;
579579
FILE *out;
580580
unsigned char key[MAXBLOCKSIZE], plaintext[MAXBLOCKSIZE*2], tag[MAXBLOCKSIZE];
@@ -632,10 +632,10 @@ void gcm_gen(void)
632632
fprintf(out, "\n");
633633
}
634634
fclose(out);
635-
#endif
636635
}
636+
#endif
637637

638-
void base64_gen(void)
638+
static void base64_gen(void)
639639
{
640640
FILE *out;
641641
unsigned char src[32], ch;
@@ -655,11 +655,11 @@ void base64_gen(void)
655655
fclose(out);
656656
}
657657

658-
void math_gen(void)
658+
static void math_gen(void)
659659
{
660660
}
661661

662-
void ecc_gen(void)
662+
static void ecc_gen(void)
663663
{
664664
FILE *out;
665665
unsigned char str[512];
@@ -701,9 +701,9 @@ void ecc_gen(void)
701701
fclose(out);
702702
}
703703

704-
void lrw_gen(void)
705-
{
706704
#ifdef LTC_LRW_MODE
705+
static void lrw_gen(void)
706+
{
707707
FILE *out;
708708
unsigned char tweak[16], key[16], iv[16], buf[1024];
709709
int x, y, err;
@@ -765,8 +765,8 @@ void lrw_gen(void)
765765
lrw_done(&lrw);
766766
}
767767
fclose(out);
768-
#endif
769768
}
769+
#endif
770770

771771
int main(void)
772772
{

doc/crypt.tex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,30 +1397,30 @@ \chapter{Stream Ciphers}
13971397

13981398
Initialize by creating a Sosemanuk state and provide a 128- to 256-bit key to \textit{sosemanuk\_setup()}.
13991399
\begin{verbatim}
1400-
sosemanuk_state ss;
1401-
err = sosemanuk_setup(&ss, key, keylen);
1400+
sosemanuk_state st;
1401+
err = sosemanuk_setup(&st, key, keylen);
14021402
\end{verbatim}
14031403

14041404
Finish initializing with an iv of up to 128 bits.
14051405
\begin{verbatim}
1406-
err = sosemanuk_setiv(&ss, iv, ivlen);
1406+
err = sosemanuk_setiv(&st, iv, ivlen);
14071407
\end{verbatim}
14081408

14091409
For the actual encryption or decryption, call:
14101410
\begin{verbatim}
1411-
err = sosemanuk_crypt(&ss, in, inlen, out);
1411+
err = sosemanuk_crypt(&st, in, inlen, out);
14121412
\end{verbatim}
14131413

14141414
If you just want a random stream of bytes initialize the cipher with a truly random
14151415
\textit{key} (256 bits) and a truly random \textit{iv} (128 bits). After that you can
14161416
get a stream of pseudo--random bytes via:
14171417
\begin{verbatim}
1418-
err = sosemanuk_keystream(&ss, out, outlen);
1418+
err = sosemanuk_keystream(&st, out, outlen);
14191419
\end{verbatim}
14201420

14211421
When finished you should wipe the key by running \textit{sosemanuk\_done()}.
14221422
\begin{verbatim}
1423-
err = sosemanuk_done(&ss);
1423+
err = sosemanuk_done(&st);
14241424
\end{verbatim}
14251425

14261426
To do multiple encryptions and decryptions with the same key, you will want to set the iv but

src/headers/tomcrypt_cipher.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,11 +1055,11 @@ typedef struct {
10551055
unsigned ptr;
10561056
} sosemanuk_state;
10571057

1058-
int sosemanuk_setup(sosemanuk_state *ss, const unsigned char *key, unsigned long keylen);
1059-
int sosemanuk_setiv(sosemanuk_state *ss, const unsigned char *iv, unsigned long ivlen);
1060-
int sosemanuk_crypt(sosemanuk_state *ss, const unsigned char *in, unsigned long inlen, unsigned char *out);
1061-
int sosemanuk_keystream(sosemanuk_state *ss, unsigned char *out, unsigned long outlen);
1062-
int sosemanuk_done(sosemanuk_state *ss);
1058+
int sosemanuk_setup(sosemanuk_state *st, const unsigned char *key, unsigned long keylen);
1059+
int sosemanuk_setiv(sosemanuk_state *st, const unsigned char *iv, unsigned long ivlen);
1060+
int sosemanuk_crypt(sosemanuk_state *st, const unsigned char *in, unsigned long inlen, unsigned char *out);
1061+
int sosemanuk_keystream(sosemanuk_state *st, unsigned char *out, unsigned long outlen);
1062+
int sosemanuk_done(sosemanuk_state *st);
10631063
int sosemanuk_test(void);
10641064

10651065
#endif /* LTC_SOSEMANUK */

0 commit comments

Comments
 (0)