Changeset View
Changeset View
Standalone View
Standalone View
sys/crypto/chacha20/chacha-sw.c
| Show All 12 Lines | chacha20_xform_setkey(void *ctx, const uint8_t *key, int len) | ||||
| if (len != CHACHA_MINKEYLEN && len != 32) | if (len != CHACHA_MINKEYLEN && len != 32) | ||||
| return (EINVAL); | return (EINVAL); | ||||
| chacha_keysetup(ctx, key, len * 8); | chacha_keysetup(ctx, key, len * 8); | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| static void | static void | ||||
| chacha20_xform_reinit(void *ctx, const uint8_t *iv) | chacha20_xform_reinit(void *ctx, const uint8_t *iv, size_t ivlen) | ||||
markj: Still `len` here, would be nice to be consistent. | |||||
| { | { | ||||
| KASSERT(ivlen == CHACHA_NONCELEN + CHACHA_CTRLEN, | |||||
| ("%s: invalid IV length", __func__)); | |||||
| chacha_ivsetup(ctx, iv + 8, iv); | chacha_ivsetup(ctx, iv + 8, iv); | ||||
| } | } | ||||
| static void | static void | ||||
| chacha20_xform_crypt(void *ctx, const uint8_t *in, uint8_t *out) | chacha20_xform_crypt(void *ctx, const uint8_t *in, uint8_t *out) | ||||
| { | { | ||||
| chacha_encrypt_bytes(ctx, in, out, CHACHA_BLOCKLEN); | chacha_encrypt_bytes(ctx, in, out, CHACHA_BLOCKLEN); | ||||
| Show All 26 Lines | |||||
Still len here, would be nice to be consistent.