File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ spritz_random32 KEYWORD2
14
14
spritz_random32_uniform KEYWORD2
15
15
spritz_add_entropy KEYWORD2
16
16
spritz_crypt KEYWORD2
17
+ spritz_crypt_inplace KEYWORD2
17
18
spritz_hash_setup KEYWORD2
18
19
spritz_hash_update KEYWORD2
19
20
spritz_hash_final KEYWORD2
Original file line number Diff line number Diff line change @@ -479,6 +479,26 @@ spritz_crypt(spritz_ctx *ctx,
479
479
}
480
480
}
481
481
482
+ /** spritz_crypt_inplace()
483
+ * Encrypt or decrypt data chunk by XOR-ing it with the spritz keystream
484
+ * and put the output in the same buffer `data`.
485
+ * Usable only after calling spritz_setup() or spritz_setup_withiv().
486
+ *
487
+ * Parameter ctx: The context.
488
+ * Parameter data: The data to encrypt or decrypt, also the output.
489
+ * Parameter datalen: Length of the data in bytes.
490
+ */
491
+ void
492
+ spritz_crypt_inplace (spritz_ctx * ctx ,
493
+ uint8_t * data , uint16_t dataLen )
494
+ {
495
+ uint16_t i ;
496
+
497
+ for (i = 0 ; i < dataLen ; i ++ ) {
498
+ data [i ] ^= drip (ctx );
499
+ }
500
+ }
501
+
482
502
483
503
/** spritz_hash_setup()
484
504
* Setup the spritz hash state `spritz_ctx`.
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ extern "C" {
33
33
*/
34
34
#if 0
35
35
# define SPRITZ_USE_LIBC
36
- # include <string.h>
36
+ # include <string.h> /* For `memset()` */
37
37
# if !defined(__GNUC__ ) && !defined(__clang__ ) /* Not GCC or Clang. */
38
38
# warning "SPRITZ_USE_LIBC warning: Code optimization isn't off in some security functions."
39
39
# endif /* Not GCC or Clang. */
@@ -231,6 +231,19 @@ spritz_crypt(spritz_ctx *ctx,
231
231
const uint8_t * data , uint16_t dataLen ,
232
232
uint8_t * dataOut );
233
233
234
+ /** spritz_crypt_inplace()
235
+ * Encrypt or decrypt data chunk by XOR-ing it with the spritz keystream
236
+ * and put the output in the same buffer `data`.
237
+ * Usable only after calling spritz_setup() or spritz_setup_withiv().
238
+ *
239
+ * Parameter ctx: The context.
240
+ * Parameter data: The data to encrypt or decrypt, also the output.
241
+ * Parameter datalen: Length of the data in bytes.
242
+ */
243
+ void
244
+ spritz_crypt_inplace (spritz_ctx * ctx ,
245
+ uint8_t * data , uint16_t dataLen );
246
+
234
247
235
248
/** spritz_hash_setup()
236
249
* Setup the spritz hash state `spritz_ctx`.
You can’t perform that action at this time.
0 commit comments