diff options
author | 2013-12-15 21:42:35 +0000 | |
---|---|---|
committer | 2013-12-15 21:42:35 +0000 | |
commit | 5f4c1c01e607e710d6976a55b34e5a7d82535150 (patch) | |
tree | 9f1a56af01524bb805faa8a04f09e196bcb07753 | |
parent | The "value" argument to the roff(7) .nr requests ends right before (diff) | |
download | wireguard-openbsd-5f4c1c01e607e710d6976a55b34e5a7d82535150.tar.xz wireguard-openbsd-5f4c1c01e607e710d6976a55b34e5a7d82535150.zip |
add some comments and constify a constant
-rw-r--r-- | usr.bin/ssh/cipher-chachapoly.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/usr.bin/ssh/cipher-chachapoly.c b/usr.bin/ssh/cipher-chachapoly.c index 78ab8335006..9a7bb773540 100644 --- a/usr.bin/ssh/cipher-chachapoly.c +++ b/usr.bin/ssh/cipher-chachapoly.c @@ -14,7 +14,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $OpenBSD: cipher-chachapoly.c,v 1.2 2013/11/21 02:50:00 djm Exp $ */ +/* $OpenBSD: cipher-chachapoly.c,v 1.3 2013/12/15 21:42:35 djm Exp $ */ #include <sys/types.h> #include <stdarg.h> /* needed for log.h */ @@ -36,20 +36,19 @@ void chachapoly_init(struct chachapoly_ctx *ctx, /* * chachapoly_crypt() operates as following: - * Copy 'aadlen' bytes (without en/decryption) from 'src' to 'dest'. - * Theses bytes are treated as additional authenticated data. - * En/Decrypt 'len' bytes at offset 'aadlen' from 'src' to 'dest'. - * Use POLY1305_TAGLEN bytes at offset 'len'+'aadlen' as the - * authentication tag. - * This tag is written on encryption and verified on decryption. - * Both 'aadlen' and 'authlen' can be set to 0. + * En/decrypt with header key 'aadlen' bytes from 'src', storing result + * to 'dest'. The ciphertext here is treated as additional authenticated + * data for MAC calculation. + * En/decrypt 'len' bytes at offset 'aadlen' from 'src' to 'dest'. Use + * POLY1305_TAGLEN bytes at offset 'len'+'aadlen' as the authentication + * tag. This tag is written on encryption and verified on decryption. */ int chachapoly_crypt(struct chachapoly_ctx *ctx, u_int seqnr, u_char *dest, const u_char *src, u_int len, u_int aadlen, u_int authlen, int do_encrypt) { u_char seqbuf[8]; - u_char one[8] = { 1, 0, 0, 0, 0, 0, 0, 0 }; /* NB. little-endian */ + const u_char one[8] = { 1, 0, 0, 0, 0, 0, 0, 0 }; /* NB little-endian */ u_char expected_tag[POLY1305_TAGLEN], poly_key[POLY1305_KEYLEN]; int r = -1; @@ -74,7 +73,7 @@ chachapoly_crypt(struct chachapoly_ctx *ctx, u_int seqnr, u_char *dest, goto out; } /* Crypt additional data */ - if (aadlen) { + if (aadlen) { chacha_ivsetup(&ctx->header_ctx, seqbuf, NULL); chacha_encrypt_bytes(&ctx->header_ctx, src, dest, aadlen); } @@ -95,6 +94,7 @@ chachapoly_crypt(struct chachapoly_ctx *ctx, u_int seqnr, u_char *dest, return r; } +/* Decrypt and extract the encrypted packet length */ int chachapoly_get_length(struct chachapoly_ctx *ctx, u_int *plenp, u_int seqnr, const u_char *cp, u_int len) |