Changeset View
Changeset View
Standalone View
Standalone View
sys/crypto/openssl/ossl_chacha20.c
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | if (inlen < CHACHA_BLK_SIZE) { | ||||
in = inseg; | in = inseg; | ||||
if (outlen < CHACHA_BLK_SIZE) { | if (outlen < CHACHA_BLK_SIZE) { | ||||
out = block; | out = block; | ||||
outlen = CHACHA_BLK_SIZE; | outlen = CHACHA_BLK_SIZE; | ||||
} else | } else | ||||
out = outseg; | out = outseg; | ||||
/* Figure out how many blocks we can encrypt/decrypt at once. */ | /* Figure out how many blocks we can encrypt/decrypt at once. */ | ||||
todo = rounddown(MIN(inlen, outlen), CHACHA_BLK_SIZE); | todo = rounddown(MIN(resid, MIN(inlen, outlen)), | ||||
CHACHA_BLK_SIZE); | |||||
#ifdef __LP64__ | #ifdef __LP64__ | ||||
/* ChaCha20_ctr32() assumes length is <= 4GB. */ | /* ChaCha20_ctr32() assumes length is <= 4GB. */ | ||||
todo = (uint32_t)todo; | todo = (uint32_t)todo; | ||||
#endif | #endif | ||||
/* Truncate if the 32-bit counter would roll over. */ | /* Truncate if the 32-bit counter would roll over. */ | ||||
next_counter = counter[0] + todo / CHACHA_BLK_SIZE; | next_counter = counter[0] + todo / CHACHA_BLK_SIZE; | ||||
▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | if (inlen < CHACHA_BLK_SIZE) { | ||||
in = inseg; | in = inseg; | ||||
if (outlen < CHACHA_BLK_SIZE) { | if (outlen < CHACHA_BLK_SIZE) { | ||||
out = block; | out = block; | ||||
outlen = CHACHA_BLK_SIZE; | outlen = CHACHA_BLK_SIZE; | ||||
} else | } else | ||||
out = outseg; | out = outseg; | ||||
/* Figure out how many blocks we can encrypt/decrypt at once. */ | /* Figure out how many blocks we can encrypt/decrypt at once. */ | ||||
todo = rounddown(MIN(inlen, outlen), CHACHA_BLK_SIZE); | todo = rounddown(MIN(resid, MIN(inlen, outlen)), | ||||
CHACHA_BLK_SIZE); | |||||
#ifdef __LP64__ | #ifdef __LP64__ | ||||
/* ChaCha20_ctr32() assumes length is <= 4GB. */ | /* ChaCha20_ctr32() assumes length is <= 4GB. */ | ||||
todo = (uint32_t)todo; | todo = (uint32_t)todo; | ||||
#endif | #endif | ||||
/* Truncate if the 32-bit counter would roll over. */ | /* Truncate if the 32-bit counter would roll over. */ | ||||
next_counter = counter[0] + todo / CHACHA_BLK_SIZE; | next_counter = counter[0] + todo / CHACHA_BLK_SIZE; | ||||
▲ Show 20 Lines • Show All 154 Lines • ▼ Show 20 Lines | if (inlen < CHACHA_BLK_SIZE) { | ||||
in = inseg; | in = inseg; | ||||
if (outlen < CHACHA_BLK_SIZE) { | if (outlen < CHACHA_BLK_SIZE) { | ||||
out = block; | out = block; | ||||
outlen = CHACHA_BLK_SIZE; | outlen = CHACHA_BLK_SIZE; | ||||
} else | } else | ||||
out = outseg; | out = outseg; | ||||
/* Figure out how many blocks we can encrypt/decrypt at once. */ | /* Figure out how many blocks we can encrypt/decrypt at once. */ | ||||
todo = rounddown(MIN(inlen, outlen), CHACHA_BLK_SIZE); | todo = rounddown(MIN(resid, MIN(inlen, outlen)), | ||||
CHACHA_BLK_SIZE); | |||||
#ifdef __LP64__ | #ifdef __LP64__ | ||||
/* ChaCha20_ctr32() assumes length is <= 4GB. */ | /* ChaCha20_ctr32() assumes length is <= 4GB. */ | ||||
todo = (uint32_t)todo; | todo = (uint32_t)todo; | ||||
#endif | #endif | ||||
/* Truncate if the 32-bit counter would roll over. */ | /* Truncate if the 32-bit counter would roll over. */ | ||||
next_counter = counter[0] + todo / CHACHA_BLK_SIZE; | next_counter = counter[0] + todo / CHACHA_BLK_SIZE; | ||||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |