progs/perftest.c: Use from Glibc syscall numbers.
[catacomb] / symm / salsa20.h
index 7b2d00b..7f3059e 100644 (file)
@@ -47,6 +47,7 @@
 /*----- Constants ---------------------------------------------------------*/
 
 #define SALSA20_NONCESZ 8u
+#define SALSA20_IETF_NONCESZ 12u
 #define SALSA20_KEYSZ 32u
 #define SALSA20_OUTSZ 64u
 
@@ -63,8 +64,8 @@ typedef uint32 salsa20_matrix[16];
 
 typedef struct salsa20_ctx {
   salsa20_matrix a;
-  octet buf[SALSA20_OUTSZ];
-  size_t bufi;
+  octet b[SALSA20_OUTSZ];
+  unsigned off;
 } salsa20_ctx;
 
 #define XSALSA20_DEFCTX(name)                                          \
@@ -91,10 +92,11 @@ extern void salsa20_init(salsa20_ctx */*ctx*/,
                         const void */*key*/, size_t /*ksz*/,
                         const void */*nonce*/);
 
-/* --- @salsa20_setnonce@ --- *
+/* --- @salsa20_setnonce{,_ietf}@ --- *
  *
  * Arguments:  @salsa20_ctx *ctx@ = pointer to context
- *             @const void *nonce@ = the nonce (@SALSA20_NONCESZ@ bytes)
+ *             @const void *nonce@ = the nonce (@SALSA20_NONCESZ@ or
+ *                     @SALSA20_IETF_NONCESZ@ bytes)
  *
  * Returns:    ---
  *
@@ -104,8 +106,10 @@ extern void salsa20_init(salsa20_ctx */*ctx*/,
  */
 
 extern void salsa20_setnonce(salsa20_ctx */*ctx*/, const void */*nonce*/);
+extern void salsa20_setnonce_ietf(salsa20_ctx */*ctx*/,
+                                 const void */*nonce*/);
 
-/* --- @salsa20_seek{,u64}@ --- *
+/* --- @salsa20_seek{,u64,_ietf}@ --- *
  *
  * Arguments:  @salsa20_ctx *ctx@ = pointer to context
  *             @unsigned long i@, @kludge64 i@ = new position to set
@@ -120,8 +124,9 @@ extern void salsa20_setnonce(salsa20_ctx */*ctx*/, const void */*nonce*/);
 
 extern void salsa20_seek(salsa20_ctx */*ctx*/, unsigned long /*i*/);
 extern void salsa20_seeku64(salsa20_ctx */*ctx*/, kludge64 /*i*/);
+extern void salsa20_seek_ietf(salsa20_ctx */*ctx*/, uint32 /*i*/);
 
-/* --- @salsa20_tell{,u64}@ --- *
+/* --- @salsa20_tell{,u64,_ietf}@ --- *
  *
  * Arguments:  @salsa20_ctx *ctx@ = pointer to context
  *
@@ -131,6 +136,7 @@ extern void salsa20_seeku64(salsa20_ctx */*ctx*/, kludge64 /*i*/);
 
 extern unsigned long salsa20_tell(salsa20_ctx */*ctx*/);
 extern kludge64 salsa20_tellu64(salsa20_ctx */*ctx*/);
+extern uint32 salsa20_tell_ietf(salsa20_ctx */*ctx*/);
 
 /* --- @salsa20{,12,8}_encrypt@ --- *
  *
@@ -229,7 +235,7 @@ extern void xsalsa2012_setnonce(xsalsa2012_ctx */*ctx*/,
 extern void xsalsa208_setnonce(xsalsa208_ctx */*ctx*/,
                               const void */*nonce*/);
 
-/* --- @xsalsa20{,12,8}_seek{,u64}@ --- *
+/* --- @xsalsa20{,12,8}_seek@, @xsalsa20{,12,8}_seeku64@ --- *
  *
  * Arguments:  @xsalsa20R_ctx *ctx@ = pointer to context
  *             @unsigned long i@, @kludge64 i@ = new position to set
@@ -253,7 +259,7 @@ extern void xsalsa20_seeku64(xsalsa20_ctx */*ctx*/, kludge64 /*i*/);
 extern void xsalsa2012_seeku64(xsalsa2012_ctx */*ctx*/, kludge64 /*i*/);
 extern void xsalsa208_seeku64(xsalsa208_ctx */*ctx*/, kludge64 /*i*/);
 
-/* --- @xsalsa20{,12,8}_tell{,u64}@ --- *
+/* --- @xsalsa20{,12,8}_tell@, @xsalsa20{,12,8}_tellu64@ --- *
  *
  * Arguments:  @salsa20_ctx *ctx@ = pointer to context
  *
@@ -304,21 +310,26 @@ extern void xsalsa208_encrypt(xsalsa208_ctx */*ctx*/,
 extern const octet salsa20_keysz[];
 #define salsa2012_keysz salsa20_keysz
 #define salsa208_keysz salsa20_keysz
+#define salsa20_ietf_keysz salsa20_keysz
+#define salsa2012_ietf_keysz salsa20_keysz
+#define salsa208_ietf_keysz salsa20_keysz
 #define xsalsa20_keysz salsa20_keysz
 #define xsalsa2012_keysz salsa20_keysz
 #define xsalsa208_keysz salsa20_keysz
 
-const gccipher salsa20, salsa2012, salsa208;
-const gccipher xsalsa20, xsalsa2012, xsalsa208;
+extern const gccipher salsa20, salsa2012, salsa208;
+extern const gccipher salsa20_ietf, salsa2012_ietf, salsa208_ietf;
+extern const gccipher xsalsa20, xsalsa2012, xsalsa208;
 
 /*----- Generic random number generator interface -------------------------*/
 
-/* --- @salsa20{,12,8}_rand@, @xsalsa20{,12,8}_rand@ --- *
+/* --- @salsa20{,12,8}{,_ietf}_rand@, @xsalsa20{,12,8}{,_ietf}_rand@ --- *
  *
  * Arguments:          @const void *k@ = pointer to key material
  *                     @size_t ksz@ = size of key material
  *                     @const void *n@ = pointer to nonce or null
- *                             (@SALSA20_NONCESZ@ or @XSALSA20_NONCESZ@)
+ *                             (@SALSA20_NONCESZ@, @SALSA20_IETF_NONCESZ@,
+ *                             or @XSALSA20_NONCESZ@)
  *
  * Returns:            Pointer to generic random number generator instance.
  *
@@ -332,6 +343,12 @@ extern grand *salsa2012_rand(const void */*k*/, size_t /*ksz*/,
                             const void */*n*/);
 extern grand *salsa208_rand(const void */*k*/, size_t /*ksz*/,
                            const void */*n*/);
+extern grand *salsa20_ietf_rand(const void */*k*/, size_t /*ksz*/,
+                               const void */*n*/);
+extern grand *salsa2012_ietf_rand(const void */*k*/, size_t /*ksz*/,
+                                 const void */*n*/);
+extern grand *salsa208_ietf_rand(const void */*k*/, size_t /*ksz*/,
+                                const void */*n*/);
 extern grand *xsalsa20_rand(const void */*k*/, size_t /*ksz*/,
                            const void */*n*/);
 extern grand *xsalsa2012_rand(const void */*k*/, size_t /*ksz*/,