-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
crypto: chacha20poly1305 - import construction and selftest from Zinc
This incorporates the chacha20poly1305 from the Zinc library, retaining the library interface, but replacing the implementation with calls into the code that already existed in the kernel's crypto API. Note that this library API does not implement RFC7539 fully, given that it is limited to 64-bit nonces. (The 96-bit nonce version that was part of the selftest only has been removed, along with the 96-bit nonce test vectors that only tested the selftest but not the actual library itself) Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
- Loading branch information
Ard Biesheuvel
authored and
Herbert Xu
committed
Nov 17, 2019
1 parent
d8f1308
commit ed20078
Showing
5 changed files
with
7,615 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 OR MIT */ | ||
/* | ||
* Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. | ||
*/ | ||
|
||
#ifndef __CHACHA20POLY1305_H | ||
#define __CHACHA20POLY1305_H | ||
|
||
#include <linux/types.h> | ||
|
||
enum chacha20poly1305_lengths { | ||
XCHACHA20POLY1305_NONCE_SIZE = 24, | ||
CHACHA20POLY1305_KEY_SIZE = 32, | ||
CHACHA20POLY1305_AUTHTAG_SIZE = 16 | ||
}; | ||
|
||
void chacha20poly1305_encrypt(u8 *dst, const u8 *src, const size_t src_len, | ||
const u8 *ad, const size_t ad_len, | ||
const u64 nonce, | ||
const u8 key[CHACHA20POLY1305_KEY_SIZE]); | ||
|
||
bool __must_check | ||
chacha20poly1305_decrypt(u8 *dst, const u8 *src, const size_t src_len, | ||
const u8 *ad, const size_t ad_len, const u64 nonce, | ||
const u8 key[CHACHA20POLY1305_KEY_SIZE]); | ||
|
||
void xchacha20poly1305_encrypt(u8 *dst, const u8 *src, const size_t src_len, | ||
const u8 *ad, const size_t ad_len, | ||
const u8 nonce[XCHACHA20POLY1305_NONCE_SIZE], | ||
const u8 key[CHACHA20POLY1305_KEY_SIZE]); | ||
|
||
bool __must_check xchacha20poly1305_decrypt( | ||
u8 *dst, const u8 *src, const size_t src_len, const u8 *ad, | ||
const size_t ad_len, const u8 nonce[XCHACHA20POLY1305_NONCE_SIZE], | ||
const u8 key[CHACHA20POLY1305_KEY_SIZE]); | ||
|
||
#endif /* __CHACHA20POLY1305_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.