Added const-qualifiers.
This commit is contained in:
parent
0b400eb99f
commit
6d8f729825
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rijndael-api-fst.c,v 1.19 2005/12/11 12:20:52 christos Exp $ */
|
||||
/* $NetBSD: rijndael-api-fst.c,v 1.20 2007/01/21 23:00:08 cbiere Exp $ */
|
||||
|
||||
/**
|
||||
* rijndael-api-fst.c
|
||||
|
@ -38,7 +38,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: rijndael-api-fst.c,v 1.19 2005/12/11 12:20:52 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: rijndael-api-fst.c,v 1.20 2007/01/21 23:00:08 cbiere Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#ifdef _KERNEL
|
||||
|
@ -52,7 +52,7 @@ __KERNEL_RCSID(0, "$NetBSD: rijndael-api-fst.c,v 1.19 2005/12/11 12:20:52 christ
|
|||
#include <crypto/rijndael/rijndael-alg-fst.h>
|
||||
#include <crypto/rijndael/rijndael-api-fst.h>
|
||||
|
||||
int rijndael_makeKey(keyInstance *key, BYTE direction, int keyLen, char *keyMaterial) {
|
||||
int rijndael_makeKey(keyInstance *key, BYTE direction, int keyLen, const char *keyMaterial) {
|
||||
u_int8_t cipherKey[RIJNDAEL_MAXKB];
|
||||
|
||||
if (key == NULL) {
|
||||
|
@ -86,7 +86,7 @@ int rijndael_makeKey(keyInstance *key, BYTE direction, int keyLen, char *keyMate
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
int rijndael_cipherInit(cipherInstance *cipher, BYTE mode, char *IV) {
|
||||
int rijndael_cipherInit(cipherInstance *cipher, BYTE mode, const char *IV) {
|
||||
if ((mode == MODE_ECB) || (mode == MODE_CBC) || (mode == MODE_CFB1)) {
|
||||
cipher->mode = mode;
|
||||
} else {
|
||||
|
@ -101,7 +101,7 @@ int rijndael_cipherInit(cipherInstance *cipher, BYTE mode, char *IV) {
|
|||
}
|
||||
|
||||
int rijndael_blockEncrypt(cipherInstance *cipher, keyInstance *key,
|
||||
BYTE *input, int inputLen, BYTE *outBuffer) {
|
||||
const BYTE *input, int inputLen, BYTE *outBuffer) {
|
||||
int i, k, t, numBlocks;
|
||||
u_int8_t block[16], *iv;
|
||||
|
||||
|
@ -173,7 +173,7 @@ int rijndael_blockEncrypt(cipherInstance *cipher, keyInstance *key,
|
|||
* @return length in octets (not bits) of the encrypted output buffer.
|
||||
*/
|
||||
int rijndael_padEncrypt(cipherInstance *cipher, keyInstance *key,
|
||||
BYTE *input, int inputOctets, BYTE *outBuffer) {
|
||||
const BYTE *input, int inputOctets, BYTE *outBuffer) {
|
||||
int i, numBlocks, padLen;
|
||||
u_int8_t block[16], *iv;
|
||||
|
||||
|
@ -231,7 +231,7 @@ int rijndael_padEncrypt(cipherInstance *cipher, keyInstance *key,
|
|||
}
|
||||
|
||||
int rijndael_blockDecrypt(cipherInstance *cipher, keyInstance *key,
|
||||
BYTE *input, int inputLen, BYTE *outBuffer) {
|
||||
const BYTE *input, int inputLen, BYTE *outBuffer) {
|
||||
int i, k, t, numBlocks;
|
||||
u_int8_t block[16], *iv;
|
||||
|
||||
|
@ -295,7 +295,7 @@ int rijndael_blockDecrypt(cipherInstance *cipher, keyInstance *key,
|
|||
}
|
||||
|
||||
int rijndael_padDecrypt(cipherInstance *cipher, keyInstance *key,
|
||||
BYTE *input, int inputOctets, BYTE *outBuffer) {
|
||||
const BYTE *input, int inputOctets, BYTE *outBuffer) {
|
||||
int i, numBlocks, padLen;
|
||||
u_int8_t block[16];
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rijndael-api-fst.h,v 1.7 2005/12/11 12:20:52 christos Exp $ */
|
||||
/* $NetBSD: rijndael-api-fst.h,v 1.8 2007/01/21 23:00:08 cbiere Exp $ */
|
||||
|
||||
/**
|
||||
* rijndael-api-fst.h
|
||||
|
@ -90,16 +90,16 @@ typedef struct { /* changed order of the components */
|
|||
|
||||
/* Function prototypes */
|
||||
|
||||
int rijndael_makeKey(keyInstance *, BYTE, int, char *);
|
||||
int rijndael_makeKey(keyInstance *, BYTE, int, const char *);
|
||||
|
||||
int rijndael_cipherInit(cipherInstance *, BYTE, char *);
|
||||
int rijndael_cipherInit(cipherInstance *, BYTE, const char *);
|
||||
|
||||
int rijndael_blockEncrypt(cipherInstance *, keyInstance *, BYTE *, int, BYTE *);
|
||||
int rijndael_blockEncrypt(cipherInstance *, keyInstance *, const BYTE *, int, BYTE *);
|
||||
|
||||
int rijndael_padEncrypt(cipherInstance *, keyInstance *, BYTE *, int, BYTE *);
|
||||
int rijndael_padEncrypt(cipherInstance *, keyInstance *, const BYTE *, int, BYTE *);
|
||||
|
||||
int rijndael_blockDecrypt(cipherInstance *, keyInstance *, BYTE *, int, BYTE *);
|
||||
int rijndael_blockDecrypt(cipherInstance *, keyInstance *, const BYTE *, int, BYTE *);
|
||||
|
||||
int rijndael_padDecrypt(cipherInstance *, keyInstance *, BYTE *, int, BYTE *);
|
||||
int rijndael_padDecrypt(cipherInstance *, keyInstance *, const BYTE *, int, BYTE *);
|
||||
|
||||
#endif /* __RIJNDAEL_API_FST_H */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cgd_crypto.c,v 1.6 2006/12/01 15:52:55 christos Exp $ */
|
||||
/* $NetBSD: cgd_crypto.c,v 1.7 2007/01/21 23:00:08 cbiere Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -44,7 +44,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: cgd_crypto.c,v 1.6 2006/12/01 15:52:55 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: cgd_crypto.c,v 1.7 2007/01/21 23:00:08 cbiere Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -82,7 +82,7 @@ cryptfuncs_find(const char *alg)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
typedef void (*cipher_func)(void *, void *, void *, size_t);
|
||||
typedef void (*cipher_func)(void *, void *, const void *, size_t);
|
||||
|
||||
void
|
||||
cgd_cipher_uio_cbc(void *privdata, cipher_func cipher,
|
||||
|
@ -173,11 +173,11 @@ struct aes_encdata {
|
|||
u_int8_t ae_iv[16]; /* Initialization Vector */
|
||||
};
|
||||
|
||||
static void aes_cbc_enc_int(void *, void *, void *, size_t);
|
||||
static void aes_cbc_dec_int(void *, void *, void *, size_t);
|
||||
static void aes_cbc_enc_int(void *, void *, const void *, size_t);
|
||||
static void aes_cbc_dec_int(void *, void *, const void *, size_t);
|
||||
|
||||
void *
|
||||
cgd_cipher_aes_init(size_t keylen, void *key, size_t *blocksize)
|
||||
cgd_cipher_aes_init(size_t keylen, const void *key, size_t *blocksize)
|
||||
{
|
||||
struct aes_privdata *ap;
|
||||
|
||||
|
@ -207,7 +207,7 @@ cgd_cipher_aes_destroy(void *data)
|
|||
}
|
||||
|
||||
void
|
||||
aes_cbc_enc_int(void *privdata, void *dst, void *src, size_t len)
|
||||
aes_cbc_enc_int(void *privdata, void *dst, const void *src, size_t len)
|
||||
{
|
||||
struct aes_encdata *ae = privdata;
|
||||
cipherInstance cipher;
|
||||
|
@ -218,14 +218,14 @@ aes_cbc_enc_int(void *privdata, void *dst, void *src, size_t len)
|
|||
}
|
||||
|
||||
void
|
||||
aes_cbc_dec_int(void *privdata, void *dst, void *src, size_t len)
|
||||
aes_cbc_dec_int(void *privdata, void *dst, const void *src, size_t len)
|
||||
{
|
||||
struct aes_encdata *ae = privdata;
|
||||
cipherInstance cipher;
|
||||
|
||||
rijndael_cipherInit(&cipher, MODE_CBC, ae->ae_iv);
|
||||
rijndael_blockDecrypt(&cipher, ae->ae_key, src, len * 8, dst);
|
||||
(void)memcpy(ae->ae_iv, (u_int8_t *)src + (len - 16), 16);
|
||||
(void)memcpy(ae->ae_iv, (const u_int8_t *)src + (len - 16), 16);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -272,8 +272,8 @@ struct c3des_privdata {
|
|||
des_key_schedule cp_key3;
|
||||
};
|
||||
|
||||
static void c3des_cbc_enc_int(void *, void *, void *, size_t);
|
||||
static void c3des_cbc_dec_int(void *, void *, void *, size_t);
|
||||
static void c3des_cbc_enc_int(void *, void *, const void *, size_t);
|
||||
static void c3des_cbc_dec_int(void *, void *, const void *, size_t);
|
||||
|
||||
struct c3des_encdata {
|
||||
des_key_schedule *ce_key1;
|
||||
|
@ -283,10 +283,11 @@ struct c3des_encdata {
|
|||
};
|
||||
|
||||
void *
|
||||
cgd_cipher_3des_init(size_t keylen, void *key, size_t *blocksize)
|
||||
cgd_cipher_3des_init(size_t keylen, const void *key, size_t *blocksize)
|
||||
{
|
||||
struct c3des_privdata *cp;
|
||||
int error = 0;
|
||||
des_cblock *block;
|
||||
|
||||
if (!blocksize)
|
||||
return NULL;
|
||||
|
@ -297,9 +298,10 @@ cgd_cipher_3des_init(size_t keylen, void *key, size_t *blocksize)
|
|||
cp = malloc(sizeof(*cp), M_DEVBUF, 0);
|
||||
if (!cp)
|
||||
return NULL;
|
||||
error = des_key_sched((des_cblock *)key, cp->cp_key1);
|
||||
error |= des_key_sched((des_cblock *)key + 1, cp->cp_key2);
|
||||
error |= des_key_sched((des_cblock *)key + 2, cp->cp_key3);
|
||||
block = __UNCONST(key);
|
||||
error = des_key_sched(block, cp->cp_key1);
|
||||
error |= des_key_sched(block + 1, cp->cp_key2);
|
||||
error |= des_key_sched(block + 2, cp->cp_key3);
|
||||
if (error) {
|
||||
(void)memset(cp, 0, sizeof(*cp));
|
||||
free(cp, M_DEVBUF);
|
||||
|
@ -318,23 +320,23 @@ cgd_cipher_3des_destroy(void *data)
|
|||
}
|
||||
|
||||
static void
|
||||
c3des_cbc_enc_int(void *privdata, void *dst, void *src, size_t len)
|
||||
c3des_cbc_enc_int(void *privdata, void *dst, const void *src, size_t len)
|
||||
{
|
||||
struct c3des_encdata *ce = privdata;
|
||||
|
||||
des_ede3_cbc_encrypt(src, dst, len, *ce->ce_key1, *ce->ce_key2,
|
||||
*ce->ce_key3, (des_cblock *)ce->ce_iv, 1);
|
||||
(void)memcpy(ce->ce_iv, (u_int8_t *)dst + (len - 8), 8);
|
||||
(void)memcpy(ce->ce_iv, (const u_int8_t *)dst + (len - 8), 8);
|
||||
}
|
||||
|
||||
static void
|
||||
c3des_cbc_dec_int(void *privdata, void *dst, void *src, size_t len)
|
||||
c3des_cbc_dec_int(void *privdata, void *dst, const void *src, size_t len)
|
||||
{
|
||||
struct c3des_encdata *ce = privdata;
|
||||
|
||||
des_ede3_cbc_encrypt(src, dst, len, *ce->ce_key1, *ce->ce_key2,
|
||||
*ce->ce_key3, (des_cblock *)ce->ce_iv, 0);
|
||||
(void)memcpy(ce->ce_iv, (u_int8_t *)src + (len - 8), 8);
|
||||
(void)memcpy(ce->ce_iv, (const u_int8_t *)src + (len - 8), 8);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -376,8 +378,8 @@ struct cryptfuncs cgd_BF_funcs = {
|
|||
cgd_cipher_bf_cbc,
|
||||
};
|
||||
|
||||
static void bf_cbc_enc_int(void *, void *, void *, size_t);
|
||||
static void bf_cbc_dec_int(void *, void *, void *, size_t);
|
||||
static void bf_cbc_enc_int(void *, void *, const void *, size_t);
|
||||
static void bf_cbc_dec_int(void *, void *, const void *, size_t);
|
||||
|
||||
struct bf_privdata {
|
||||
BF_KEY bp_key;
|
||||
|
@ -389,7 +391,7 @@ struct bf_encdata {
|
|||
};
|
||||
|
||||
void *
|
||||
cgd_cipher_bf_init(size_t keylen, void *key, size_t *blocksize)
|
||||
cgd_cipher_bf_init(size_t keylen, const void *key, size_t *blocksize)
|
||||
{
|
||||
struct bf_privdata *bp;
|
||||
|
||||
|
@ -418,7 +420,7 @@ cgd_cipher_bf_destroy(void *data)
|
|||
}
|
||||
|
||||
void
|
||||
bf_cbc_enc_int(void *privdata, void *dst, void *src, size_t len)
|
||||
bf_cbc_enc_int(void *privdata, void *dst, const void *src, size_t len)
|
||||
{
|
||||
struct bf_encdata *be = privdata;
|
||||
|
||||
|
@ -427,12 +429,12 @@ bf_cbc_enc_int(void *privdata, void *dst, void *src, size_t len)
|
|||
}
|
||||
|
||||
void
|
||||
bf_cbc_dec_int(void *privdata, void *dst, void *src, size_t len)
|
||||
bf_cbc_dec_int(void *privdata, void *dst, const void *src, size_t len)
|
||||
{
|
||||
struct bf_encdata *be = privdata;
|
||||
|
||||
BF_cbc_encrypt(src, dst, len, be->be_key, be->be_iv, 0);
|
||||
(void)memcpy(be->be_iv, (u_int8_t *)src + (len - 8), 8);
|
||||
(void)memcpy(be->be_iv, (const u_int8_t *)src + (len - 8), 8);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cgd_crypto.h,v 1.4 2006/12/01 15:52:55 christos Exp $ */
|
||||
/* $NetBSD: cgd_crypto.h,v 1.5 2007/01/21 23:00:08 cbiere Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
|
@ -43,7 +43,7 @@
|
|||
#define CGD_CIPHER_DECRYPT 1
|
||||
#define CGD_CIPHER_ENCRYPT 2
|
||||
|
||||
typedef void *(cfunc_init)(size_t, void *, size_t *);
|
||||
typedef void *(cfunc_init)(size_t, const void *, size_t *);
|
||||
typedef void (cfunc_destroy)(void *);
|
||||
typedef void (cfunc_cipher)(void *, struct uio *, struct uio *, void *, int);
|
||||
|
||||
|
|
Loading…
Reference in New Issue