aboutsummaryrefslogtreecommitdiff
path: root/sys/crypto
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2016-05-26 19:29:29 +0000
committerConrad Meyer <cem@FreeBSD.org>2016-05-26 19:29:29 +0000
commit571ebf7685f6f4c14d29d3efba04a558def65bd4 (patch)
treea3f8dd317ab9b8bf2071cc3dc88766e3294342a7 /sys/crypto
parentccabe8433fa57a48fd1518de304f70451fbaeeb7 (diff)
Notes
Diffstat (limited to 'sys/crypto')
-rw-r--r--sys/crypto/aesni/aesni.h10
-rw-r--r--sys/crypto/aesni/aesni_wrap.c12
-rw-r--r--sys/crypto/sha1.c6
-rw-r--r--sys/crypto/sha1.h12
-rw-r--r--sys/crypto/sha2/sha256.h2
-rw-r--r--sys/crypto/sha2/sha256c.c6
-rw-r--r--sys/crypto/sha2/sha384.h2
-rw-r--r--sys/crypto/sha2/sha512.h2
-rw-r--r--sys/crypto/sha2/sha512c.c8
-rw-r--r--sys/crypto/siphash/siphash.c8
-rw-r--r--sys/crypto/siphash/siphash.h6
11 files changed, 36 insertions, 38 deletions
diff --git a/sys/crypto/aesni/aesni.h b/sys/crypto/aesni/aesni.h
index 3d5adec79eed..b327c01cea66 100644
--- a/sys/crypto/aesni/aesni.h
+++ b/sys/crypto/aesni/aesni.h
@@ -79,23 +79,23 @@ void aesni_set_deckey(const uint8_t *encrypt_schedule /*__aligned(16)*/,
*/
void aesni_encrypt_cbc(int rounds, const void *key_schedule /*__aligned(16)*/,
size_t len, const uint8_t *from, uint8_t *to,
- const uint8_t iv[AES_BLOCK_LEN]);
+ const uint8_t iv[static AES_BLOCK_LEN]);
void aesni_decrypt_cbc(int rounds, const void *key_schedule /*__aligned(16)*/,
- size_t len, uint8_t *buf, const uint8_t iv[AES_BLOCK_LEN]);
+ size_t len, uint8_t *buf, const uint8_t iv[static AES_BLOCK_LEN]);
void aesni_encrypt_ecb(int rounds, const void *key_schedule /*__aligned(16)*/,
size_t len, const uint8_t *from, uint8_t *to);
void aesni_decrypt_ecb(int rounds, const void *key_schedule /*__aligned(16)*/,
size_t len, const uint8_t *from, uint8_t *to);
void aesni_encrypt_icm(int rounds, const void *key_schedule /*__aligned(16)*/,
size_t len, const uint8_t *from, uint8_t *to,
- const uint8_t iv[AES_BLOCK_LEN]);
+ const uint8_t iv[static AES_BLOCK_LEN]);
void aesni_encrypt_xts(int rounds, const void *data_schedule /*__aligned(16)*/,
const void *tweak_schedule /*__aligned(16)*/, size_t len,
- const uint8_t *from, uint8_t *to, const uint8_t iv[AES_BLOCK_LEN]);
+ const uint8_t *from, uint8_t *to, const uint8_t iv[static AES_BLOCK_LEN]);
void aesni_decrypt_xts(int rounds, const void *data_schedule /*__aligned(16)*/,
const void *tweak_schedule /*__aligned(16)*/, size_t len,
- const uint8_t *from, uint8_t *to, const uint8_t iv[AES_BLOCK_LEN]);
+ const uint8_t *from, uint8_t *to, const uint8_t iv[static AES_BLOCK_LEN]);
/* GCM & GHASH functions */
void AES_GCM_encrypt(const unsigned char *in, unsigned char *out,
diff --git a/sys/crypto/aesni/aesni_wrap.c b/sys/crypto/aesni/aesni_wrap.c
index e5e2a6991d9a..22e6afa8ab6f 100644
--- a/sys/crypto/aesni/aesni_wrap.c
+++ b/sys/crypto/aesni/aesni_wrap.c
@@ -55,7 +55,7 @@ struct blocks8 {
void
aesni_encrypt_cbc(int rounds, const void *key_schedule, size_t len,
- const uint8_t *from, uint8_t *to, const uint8_t iv[AES_BLOCK_LEN])
+ const uint8_t *from, uint8_t *to, const uint8_t iv[static AES_BLOCK_LEN])
{
__m128i tot, ivreg;
size_t i;
@@ -74,7 +74,7 @@ aesni_encrypt_cbc(int rounds, const void *key_schedule, size_t len,
void
aesni_decrypt_cbc(int rounds, const void *key_schedule, size_t len,
- uint8_t *buf, const uint8_t iv[AES_BLOCK_LEN])
+ uint8_t *buf, const uint8_t iv[static AES_BLOCK_LEN])
{
__m128i blocks[8];
struct blocks8 *blks;
@@ -204,7 +204,7 @@ nextc(__m128i x)
void
aesni_encrypt_icm(int rounds, const void *key_schedule, size_t len,
- const uint8_t *from, uint8_t *to, const uint8_t iv[AES_BLOCK_LEN])
+ const uint8_t *from, uint8_t *to, const uint8_t iv[static AES_BLOCK_LEN])
{
__m128i tot;
__m128i tmp1, tmp2, tmp3, tmp4;
@@ -378,7 +378,7 @@ aesni_crypt_xts_block8(int rounds, const __m128i *key_schedule, __m128i *tweak,
static void
aesni_crypt_xts(int rounds, const __m128i *data_schedule,
const __m128i *tweak_schedule, size_t len, const uint8_t *from,
- uint8_t *to, const uint8_t iv[AES_BLOCK_LEN], int do_encrypt)
+ uint8_t *to, const uint8_t iv[static AES_BLOCK_LEN], int do_encrypt)
{
__m128i tweakreg;
uint8_t tweak[AES_XTS_BLOCKSIZE] __aligned(16);
@@ -418,7 +418,7 @@ aesni_crypt_xts(int rounds, const __m128i *data_schedule,
void
aesni_encrypt_xts(int rounds, const void *data_schedule,
const void *tweak_schedule, size_t len, const uint8_t *from, uint8_t *to,
- const uint8_t iv[AES_BLOCK_LEN])
+ const uint8_t iv[static AES_BLOCK_LEN])
{
aesni_crypt_xts(rounds, data_schedule, tweak_schedule, len, from, to,
@@ -428,7 +428,7 @@ aesni_encrypt_xts(int rounds, const void *data_schedule,
void
aesni_decrypt_xts(int rounds, const void *data_schedule,
const void *tweak_schedule, size_t len, const uint8_t *from, uint8_t *to,
- const uint8_t iv[AES_BLOCK_LEN])
+ const uint8_t iv[static AES_BLOCK_LEN])
{
aesni_crypt_xts(rounds, data_schedule, tweak_schedule, len, from, to,
diff --git a/sys/crypto/sha1.c b/sys/crypto/sha1.c
index 208789ab1339..b2451c71ae8f 100644
--- a/sys/crypto/sha1.c
+++ b/sys/crypto/sha1.c
@@ -249,16 +249,14 @@ sha1_loop(ctxt, input, len)
}
void
-sha1_result(ctxt, digest0)
- struct sha1_ctxt *ctxt;
- caddr_t digest0;
+sha1_result(struct sha1_ctxt *ctxt, char digest0[static SHA1_RESULTLEN])
{
u_int8_t *digest;
digest = (u_int8_t *)digest0;
sha1_pad(ctxt);
#if BYTE_ORDER == BIG_ENDIAN
- bcopy(&ctxt->h.b8[0], digest, 20);
+ bcopy(&ctxt->h.b8[0], digest, SHA1_RESULTLEN);
#else
digest[0] = ctxt->h.b8[3]; digest[1] = ctxt->h.b8[2];
digest[2] = ctxt->h.b8[1]; digest[3] = ctxt->h.b8[0];
diff --git a/sys/crypto/sha1.h b/sys/crypto/sha1.h
index d32aa8a17842..d61709e2f6af 100644
--- a/sys/crypto/sha1.h
+++ b/sys/crypto/sha1.h
@@ -35,8 +35,8 @@
* implemented by Jun-ichiro itojun Itoh <itojun@itojun.org>
*/
-#ifndef _NETINET6_SHA1_H_
-#define _NETINET6_SHA1_H_
+#ifndef _CRYPTO_SHA1_H_
+#define _CRYPTO_SHA1_H_
struct sha1_ctxt {
union {
@@ -55,11 +55,13 @@ struct sha1_ctxt {
};
typedef struct sha1_ctxt SHA1_CTX;
+#define SHA1_RESULTLEN (160/8)
+
#ifdef _KERNEL
extern void sha1_init(struct sha1_ctxt *);
extern void sha1_pad(struct sha1_ctxt *);
extern void sha1_loop(struct sha1_ctxt *, const u_int8_t *, size_t);
-extern void sha1_result(struct sha1_ctxt *, caddr_t);
+extern void sha1_result(struct sha1_ctxt *, char[static SHA1_RESULTLEN]);
/* compatibilty with other SHA1 source codes */
#define SHA1Init(x) sha1_init((x))
@@ -67,6 +69,4 @@ extern void sha1_result(struct sha1_ctxt *, caddr_t);
#define SHA1Final(x, y) sha1_result((y), (x))
#endif /* _KERNEL */
-#define SHA1_RESULTLEN (160/8)
-
-#endif /*_NETINET6_SHA1_H_*/
+#endif /*_CRYPTO_SHA1_H_*/
diff --git a/sys/crypto/sha2/sha256.h b/sys/crypto/sha2/sha256.h
index 528af1e6c55d..17aae7def122 100644
--- a/sys/crypto/sha2/sha256.h
+++ b/sys/crypto/sha2/sha256.h
@@ -78,7 +78,7 @@ __BEGIN_DECLS
void SHA256_Init(SHA256_CTX *);
void SHA256_Update(SHA256_CTX *, const void *, size_t);
-void SHA256_Final(unsigned char [SHA256_DIGEST_LENGTH], SHA256_CTX *);
+void SHA256_Final(unsigned char [static SHA256_DIGEST_LENGTH], SHA256_CTX *);
#ifndef _KERNEL
char *SHA256_End(SHA256_CTX *, char *);
char *SHA256_Data(const void *, unsigned int, char *);
diff --git a/sys/crypto/sha2/sha256c.c b/sys/crypto/sha2/sha256c.c
index da9b02cbd1bf..79ed61dcb494 100644
--- a/sys/crypto/sha2/sha256c.c
+++ b/sys/crypto/sha2/sha256c.c
@@ -287,17 +287,17 @@ SHA256_Update(SHA256_CTX * ctx, const void *in, size_t len)
* and clears the context state.
*/
void
-SHA256_Final(unsigned char digest[32], SHA256_CTX * ctx)
+SHA256_Final(unsigned char digest[static SHA256_DIGEST_LENGTH], SHA256_CTX *ctx)
{
/* Add padding */
SHA256_Pad(ctx);
/* Write the hash */
- be32enc_vect(digest, ctx->state, 32);
+ be32enc_vect(digest, ctx->state, SHA256_DIGEST_LENGTH);
/* Clear the context state */
- memset((void *)ctx, 0, sizeof(*ctx));
+ memset(ctx, 0, sizeof(*ctx));
}
#ifdef WEAK_REFS
diff --git a/sys/crypto/sha2/sha384.h b/sys/crypto/sha2/sha384.h
index ae63ba976387..63dd948b3a8f 100644
--- a/sys/crypto/sha2/sha384.h
+++ b/sys/crypto/sha2/sha384.h
@@ -74,7 +74,7 @@ __BEGIN_DECLS
void SHA384_Init(SHA384_CTX *);
void SHA384_Update(SHA384_CTX *, const void *, size_t);
-void SHA384_Final(unsigned char [SHA384_DIGEST_LENGTH], SHA384_CTX *);
+void SHA384_Final(unsigned char [static SHA384_DIGEST_LENGTH], SHA384_CTX *);
#ifndef _KERNEL
char *SHA384_End(SHA384_CTX *, char *);
char *SHA384_Data(const void *, unsigned int, char *);
diff --git a/sys/crypto/sha2/sha512.h b/sys/crypto/sha2/sha512.h
index da0a01869b5c..b008aeaed752 100644
--- a/sys/crypto/sha2/sha512.h
+++ b/sys/crypto/sha2/sha512.h
@@ -77,7 +77,7 @@ __BEGIN_DECLS
void SHA512_Init(SHA512_CTX *);
void SHA512_Update(SHA512_CTX *, const void *, size_t);
-void SHA512_Final(unsigned char [SHA512_DIGEST_LENGTH], SHA512_CTX *);
+void SHA512_Final(unsigned char [static SHA512_DIGEST_LENGTH], SHA512_CTX *);
#ifndef _KERNEL
char *SHA512_End(SHA512_CTX *, char *);
char *SHA512_Data(const void *, unsigned int, char *);
diff --git a/sys/crypto/sha2/sha512c.c b/sys/crypto/sha2/sha512c.c
index 42ad058f5bca..5c107ea8c66d 100644
--- a/sys/crypto/sha2/sha512c.c
+++ b/sys/crypto/sha2/sha512c.c
@@ -311,7 +311,7 @@ SHA512_Update(SHA512_CTX * ctx, const void *in, size_t len)
* and clears the context state.
*/
void
-SHA512_Final(unsigned char digest[SHA512_DIGEST_LENGTH], SHA512_CTX * ctx)
+SHA512_Final(unsigned char digest[static SHA512_DIGEST_LENGTH], SHA512_CTX *ctx)
{
/* Add padding */
@@ -321,7 +321,7 @@ SHA512_Final(unsigned char digest[SHA512_DIGEST_LENGTH], SHA512_CTX * ctx)
be64enc_vect(digest, ctx->state, SHA512_DIGEST_LENGTH);
/* Clear the context state */
- memset((void *)ctx, 0, sizeof(*ctx));
+ memset(ctx, 0, sizeof(*ctx));
}
/*** SHA-384: *********************************************************/
@@ -361,7 +361,7 @@ SHA384_Update(SHA384_CTX * ctx, const void *in, size_t len)
* and clears the context state.
*/
void
-SHA384_Final(unsigned char digest[SHA384_DIGEST_LENGTH], SHA384_CTX * ctx)
+SHA384_Final(unsigned char digest[static SHA384_DIGEST_LENGTH], SHA384_CTX *ctx)
{
/* Add padding */
@@ -371,7 +371,7 @@ SHA384_Final(unsigned char digest[SHA384_DIGEST_LENGTH], SHA384_CTX * ctx)
be64enc_vect(digest, ctx->state, SHA384_DIGEST_LENGTH);
/* Clear the context state */
- memset((void *)ctx, 0, sizeof(*ctx));
+ memset(ctx, 0, sizeof(*ctx));
}
#ifdef WEAK_REFS
diff --git a/sys/crypto/siphash/siphash.c b/sys/crypto/siphash/siphash.c
index b1395d37a052..5a22312f3533 100644
--- a/sys/crypto/siphash/siphash.c
+++ b/sys/crypto/siphash/siphash.c
@@ -71,7 +71,7 @@ SipHash_InitX(SIPHASH_CTX *ctx, int rc, int rf)
}
void
-SipHash_SetKey(SIPHASH_CTX *ctx, const uint8_t key[16])
+SipHash_SetKey(SIPHASH_CTX *ctx, const uint8_t key[static SIPHASH_KEY_LENGTH])
{
uint64_t k[2];
@@ -167,7 +167,7 @@ SipHash_Update(SIPHASH_CTX *ctx, const void *src, size_t len)
}
void
-SipHash_Final(void *dst, SIPHASH_CTX *ctx)
+SipHash_Final(uint8_t dst[static SIPHASH_DIGEST_LENGTH], SIPHASH_CTX *ctx)
{
uint64_t r;
@@ -196,8 +196,8 @@ SipHash_End(SIPHASH_CTX *ctx)
}
uint64_t
-SipHashX(SIPHASH_CTX *ctx, int rc, int rf, const uint8_t key[16],
- const void *src, size_t len)
+SipHashX(SIPHASH_CTX *ctx, int rc, int rf,
+ const uint8_t key[static SIPHASH_KEY_LENGTH], const void *src, size_t len)
{
SipHash_InitX(ctx, rc, rf);
diff --git a/sys/crypto/siphash/siphash.h b/sys/crypto/siphash/siphash.h
index bfa01cbb7ac7..8bbda4f3e920 100644
--- a/sys/crypto/siphash/siphash.h
+++ b/sys/crypto/siphash/siphash.h
@@ -68,14 +68,14 @@ typedef struct _SIPHASH_CTX {
#define SipHash24_Init(x) SipHash_InitX((x), 2, 4)
#define SipHash48_Init(x) SipHash_InitX((x), 4, 8)
void SipHash_InitX(SIPHASH_CTX *, int, int);
-void SipHash_SetKey(SIPHASH_CTX *, const uint8_t [16]);
+void SipHash_SetKey(SIPHASH_CTX *, const uint8_t[static SIPHASH_KEY_LENGTH]);
void SipHash_Update(SIPHASH_CTX *, const void *, size_t);
-void SipHash_Final(void *, SIPHASH_CTX *);
+void SipHash_Final(uint8_t[static SIPHASH_DIGEST_LENGTH], SIPHASH_CTX *);
uint64_t SipHash_End(SIPHASH_CTX *);
#define SipHash24(x, y, z, i) SipHashX((x), 2, 4, (y), (z), (i));
#define SipHash48(x, y, z, i) SipHashX((x), 4, 8, (y), (z), (i));
-uint64_t SipHashX(SIPHASH_CTX *, int, int, const uint8_t [16], const void *,
+uint64_t SipHashX(SIPHASH_CTX *, int, int, const uint8_t[static SIPHASH_KEY_LENGTH], const void *,
size_t);
int SipHash24_TestVectors(void);