Changeset View
Changeset View
Standalone View
Standalone View
sys/opencrypto/xform_chacha20_poly1305.c
| Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | chacha20_poly1305_setkey(void *vctx, const uint8_t *key, int len) | ||||
| if (len != CHACHA20_POLY1305_KEY) | if (len != CHACHA20_POLY1305_KEY) | ||||
| return (EINVAL); | return (EINVAL); | ||||
| ctx->key = key; | ctx->key = key; | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| static void | static void | ||||
| chacha20_poly1305_reinit(void *vctx, const uint8_t *iv) | chacha20_poly1305_reinit(void *vctx, const uint8_t *iv, size_t ivlen) | ||||
markj: And here. | |||||
| { | { | ||||
| struct chacha20_poly1305_cipher_ctx *ctx = vctx; | struct chacha20_poly1305_cipher_ctx *ctx = vctx; | ||||
| KASSERT(ivlen == sizeof(ctx->nonce), | |||||
| ("%s: invalid nonce length", __func__)); | |||||
| /* Block 0 is used for the poly1305 key. */ | /* Block 0 is used for the poly1305 key. */ | ||||
| memcpy(ctx->nonce, iv, sizeof(ctx->nonce)); | memcpy(ctx->nonce, iv, sizeof(ctx->nonce)); | ||||
| ctx->ic = 1; | ctx->ic = 1; | ||||
| } | } | ||||
| static void | static void | ||||
| chacha20_poly1305_crypt(void *vctx, const uint8_t *in, uint8_t *out) | chacha20_poly1305_crypt(void *vctx, const uint8_t *in, uint8_t *out) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines | |||||
And here.