.Dt CRYPTO_POLY1305_AUTH 3MONOCYPHER
.Os
.Sh NAME
-.Nm crypto_poly1305_auth ,
+.Nm crypto_poly1305 ,
.Nm crypto_poly1305_init ,
.Nm crypto_poly1305_update ,
.Nm crypto_poly1305_final
.Sh SYNOPSIS
.In monocypher.h
.Ft void
-.Fo crypto_poly1305_auth
+.Fo crypto_poly1305
.Fa "uint8_t mac[16]"
.Fa "const uint8_t *message"
.Fa "size_t message_size"
Consider using authenticated encryption, implemented by
.Xr crypto_lock 3monocypher .
.Ss Direct interface
-.Fn crypto_poly1305_auth
+.Fn crypto_poly1305
produces a message authentication code for the given
message and authentication key.
The authentication key must be used only once.
const uint8_t msg[500]; /* Message to authenticate */
const uint8_t key[ 32]; /* Random secret key (use only once) */
uint8_t mac[ 16]; /* Message authentication code (MAC) */
-crypto_poly1305_auth(mac, msg, 500, key);
+crypto_poly1305(mac, msg, 500, key);
crypto_wipe(key, 32); /* The key should be wiped after use */
.Ed
.Pp
const uint8_t key [ 32]; /* The above key */
const uint8_t mac [ 16]; /* The above MAC */
uint8_t real_mac[ 16]; /* The actual MAC */
-crypto_poly1305_auth(real_mac, msg, 500, key);
+crypto_poly1305(real_mac, msg, 500, key);
crypto_wipe(key, 32); /* Wipe right away */
if (crypto_verify16(mac, real_mac)) {
/* The message is corrupted */
-crypto_poly1305_auth.3monocypher
\ No newline at end of file
+crypto_poly1305.3monocypher
\ No newline at end of file
-crypto_poly1305_auth.3monocypher
\ No newline at end of file
+crypto_poly1305.3monocypher
\ No newline at end of file
-crypto_poly1305_auth.3monocypher
\ No newline at end of file
+crypto_poly1305.3monocypher
\ No newline at end of file
.Xr crypto_lock_final 3monocypher ,
.Xr crypto_lock_init 3monocypher ,
.Xr crypto_lock_update 3monocypher ,
-.Xr crypto_poly1305_auth 3monocypher ,
+.Xr crypto_poly1305 3monocypher ,
.Xr crypto_poly1305_final 3monocypher ,
.Xr crypto_poly1305_init 3monocypher ,
.Xr crypto_poly1305_update 3monocypher ,
crypto_wipe(ctx, sizeof(*ctx));
}
-void crypto_poly1305_auth(u8 mac[16], const u8 *message,
- size_t message_size, const u8 key[32])
+void crypto_poly1305(u8 mac[16], const u8 *message,
+ size_t message_size, const u8 key[32])
{
crypto_poly1305_ctx ctx;
crypto_poly1305_init (&ctx, key);
void crypto_poly1305_final(crypto_poly1305_ctx *ctx, uint8_t mac[16]);
-void crypto_poly1305_auth(uint8_t mac[16],
- const uint8_t *message, size_t message_size,
- const uint8_t key[32]);
+void crypto_poly1305(uint8_t mac[16],
+ const uint8_t *message, size_t message_size,
+ const uint8_t key[32]);
+
+// Deprecated name
+#define crypto_poly1305_auth crypto_poly1305
////////////////
/// Blake2 b ///
static u8 out [ 16];
TIMING_START {
- crypto_poly1305_auth(out, in, SIZE, key);
+ crypto_poly1305(out, in, SIZE, key);
}
TIMING_END;
}
{
const vector *key = in;
const vector *msg = in + 1;
- crypto_poly1305_auth(out->buf, msg->buf, msg->size, key->buf);
+ crypto_poly1305(out->buf, msg->buf, msg->size, key->buf);
}
static void blake2b(const vector in[], vector *out)
crypto_poly1305_final(&ctx, mac_chunk);
// Authenticate all at once
- crypto_poly1305_auth(mac_whole, input, offset, key);
+ crypto_poly1305(mac_whole, input, offset, key);
// Compare the results (must be the same)
status |= memcmp(mac_chunk, mac_whole, 16);
u8 input[INPUT_SIZE]; p_random(input, INPUT_SIZE);
u8 key [32]; p_random(key , 32);
u8 mac [16];
- crypto_poly1305_auth(mac , input + 16, POLY1305_BLOCK_SIZE, key);
- crypto_poly1305_auth(input+i, input + 16, POLY1305_BLOCK_SIZE, key);
+ crypto_poly1305(mac , input + 16, POLY1305_BLOCK_SIZE, key);
+ crypto_poly1305(input+i, input + 16, POLY1305_BLOCK_SIZE, key);
status |= memcmp(mac, input + i, 16);
}
printf("%s: Poly1305 (overlaping i/o)\n", status != 0 ? "FAILED" : "OK");