ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/spritz/spritz.h
(Generate patch)

Comparing spritz/spritz.h (file contents):
Revision 1.4 by root, Sat Jan 10 04:14:21 2015 UTC vs.
Revision 1.5 by root, Sat Jan 10 08:29:03 2015 UTC

68uint8_t spritz_output (spritz_state *s); 68uint8_t spritz_output (spritz_state *s);
69void spritz_squeeze (spritz_state *s, void *P, size_t P_len); 69void spritz_squeeze (spritz_state *s, void *P, size_t P_len);
70uint8_t spritz_drip (spritz_state *s); 70uint8_t spritz_drip (spritz_state *s);
71 71
72/*******************************************************************************/ 72/*******************************************************************************/
73/* the spritz cipher */
74
75/* no IV is used if IV_len == 0 */
76void spritz_cipher_init (spritz_state *s, const void *K, size_t K_len, const void *IV, size_t IV_len);
77
78/* can be called multiple times/incrementally */
79/* can work inplace */
80void spritz_cipher_encrypt (spritz_state *s, const void *I, void *O, size_t len);
81void spritz_cipher_decrypt (spritz_state *s, const void *I, void *O, size_t len);
82
83/*******************************************************************************/
73/* the spritz-xor cipher */ 84/* the spritz-xor cipher */
74 85
75/* no IV is used if IV_len == 0 */ 86/* no IV is used if IV_len == 0 */
76void spritz_cipher_xor_init (spritz_state *s, const void *K, size_t K_len, const void *IV, size_t IV_len); 87static void spritz_cipher_xor_init (spritz_state *s, const void *K, size_t K_len, const void *IV, size_t IV_len);
77 88
78/* can be called multiple times/incrementally */ 89/* can be called multiple times/incrementally */
79/* can work inplace */ 90/* can work inplace */
80/* works for both encryption and decryption */ 91/* works for both encryption and decryption */
81void spritz_cipher_xor_crypt (spritz_state *s, const void *I, void *O, size_t len); 92 void spritz_cipher_xor_crypt (spritz_state *s, const void *I, void *O, size_t len);
82 93
83/*******************************************************************************/ 94/*******************************************************************************/
84/* the spritz hash */ 95/* the spritz hash */
85 96
86static void spritz_hash_init (spritz_state *s); 97static void spritz_hash_init (spritz_state *s);
94static void spritz_mac_add (spritz_state *s, const void *M, size_t M_len); /* can be called multiple times/incrementally */ 105static void spritz_mac_add (spritz_state *s, const void *M, size_t M_len); /* can be called multiple times/incrementally */
95static void spritz_mac_finish (spritz_state *s, void *H, size_t H_len); /* must be called at most once at the end */ 106static void spritz_mac_finish (spritz_state *s, void *H, size_t H_len); /* must be called at most once at the end */
96 107
97/*******************************************************************************/ 108/*******************************************************************************/
98/* spritz authenticated encryption */ 109/* spritz authenticated encryption */
110
111static void spritz_aead_init (spritz_state *s, const void *K, size_t K_len);
112static void spritz_aead_nonce (spritz_state *s, const void *N, size_t N_len); /* must be called after construction, before associated_data */
113static void spritz_aead_associated_data (spritz_state *s, const void *D, size_t D_len); /* must be called after nonce, before crypt */
114 void spritz_aead_encrypt (spritz_state *s, const void *I, void *O, size_t len);
115 void spritz_aead_decrypt (spritz_state *s, const void *I, void *O, size_t len);
116/* must be called after associated_data, only once, before finish */
117/* works for both encryption and decryption */
118static void spritz_aead_finish (spritz_state *s, void *H, size_t H_len); /* must be called at most once at the end */
119
120/*******************************************************************************/
121/* spritz authenticated encryption (xor variant) */
99 122
100static void spritz_aead_xor_init (spritz_state *s, const void *K, size_t K_len); 123static void spritz_aead_xor_init (spritz_state *s, const void *K, size_t K_len);
101static void spritz_aead_xor_nonce (spritz_state *s, const void *N, size_t N_len); /* must be called after construction, before associated_data */ 124static void spritz_aead_xor_nonce (spritz_state *s, const void *N, size_t N_len); /* must be called after construction, before associated_data */
102static void spritz_aead_xor_associated_data (spritz_state *s, const void *D, size_t D_len); /* must be called after nonce, before crypt */ 125static void spritz_aead_xor_associated_data (spritz_state *s, const void *D, size_t D_len); /* must be called after nonce, before crypt */
103 void spritz_aead_xor_crypt (spritz_state *s, const void *I, void *O, size_t len); 126 void spritz_aead_xor_crypt (spritz_state *s, const void *I, void *O, size_t len);
114static void spritz_prng_get (spritz_state *s, void *R, size_t R_len); /* get random bytes */ 137static void spritz_prng_get (spritz_state *s, void *R, size_t R_len); /* get random bytes */
115 138
116/*******************************************************************************/ 139/*******************************************************************************/
117/* inline functions - some functions are so simple, they are defined inline */ 140/* inline functions - some functions are so simple, they are defined inline */
118 141
142/* the spritz-xor cipher inline functions */
143
144static void
145spritz_cipher_xor_init (spritz_state *s, const void *K, size_t K_len, const void *IV, size_t IV_len)
146{
147 spritz_cipher_init (s, K, K_len, IV, IV_len);
148}
149
119/* the spritz hash inline functions */ 150/* the spritz hash inline functions */
120 151
121static void 152static void
122spritz_hash_init (spritz_state *s) 153spritz_hash_init (spritz_state *s)
123{ 154{
145} 176}
146 177
147/* spritz authenticated encryption inline functions */ 178/* spritz authenticated encryption inline functions */
148 179
149static void 180static void
181spritz_aead_init (spritz_state *s, const void *K, size_t K_len)
182{
183 spritz_mac_init (s, K, K_len);
184}
185
186static void
187spritz_aead_nonce (spritz_state *s, const void *N, size_t N_len)
188{
189 spritz_absorb_and_stop (s, N, N_len);
190}
191
192static void
193spritz_aead_associated_data (spritz_state *s, const void *D, size_t D_len)
194{
195 spritz_absorb_and_stop (s, D, D_len);
196}
197
198static void
199spritz_aead_finish (spritz_state *s, void *H, size_t H_len)
200{
201 spritz_mac_finish (s, H, H_len);
202}
203
204/* spritz authenticated encryption (xor variant) inline functions */
205
206static void
150spritz_aead_xor_init (spritz_state *s, const void *K, size_t K_len) 207spritz_aead_xor_init (spritz_state *s, const void *K, size_t K_len)
151{ 208{
152 spritz_mac_init (s, K, K_len); 209 spritz_mac_init (s, K, K_len);
153} 210}
154 211

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines