Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3b5cf20c authored by Herbert Xu's avatar Herbert Xu
Browse files

sunrpc: Use skcipher and ahash/shash



This patch replaces uses of blkcipher with skcipher and the long
obsolete hash interface with either shash (for non-SG users) and
ahash.

Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 2731a944
Loading
Loading
Loading
Loading
+16 −16
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@
 *
 */

#include <linux/crypto.h>
#include <crypto/skcipher.h>
#include <linux/sunrpc/auth_gss.h>
#include <linux/sunrpc/gss_err.h>
#include <linux/sunrpc/gss_asn1.h>
@@ -71,10 +71,10 @@ struct gss_krb5_enctype {
	const u32		keyed_cksum;	/* is it a keyed cksum? */
	const u32		keybytes;	/* raw key len, in bytes */
	const u32		keylength;	/* final key len, in bytes */
	u32 (*encrypt) (struct crypto_blkcipher *tfm,
	u32 (*encrypt) (struct crypto_skcipher *tfm,
			void *iv, void *in, void *out,
			int length);		/* encryption function */
	u32 (*decrypt) (struct crypto_blkcipher *tfm,
	u32 (*decrypt) (struct crypto_skcipher *tfm,
			void *iv, void *in, void *out,
			int length);		/* decryption function */
	u32 (*mk_key) (const struct gss_krb5_enctype *gk5e,
@@ -98,12 +98,12 @@ struct krb5_ctx {
	u32			enctype;
	u32			flags;
	const struct gss_krb5_enctype *gk5e; /* enctype-specific info */
	struct crypto_blkcipher	*enc;
	struct crypto_blkcipher	*seq;
	struct crypto_blkcipher *acceptor_enc;
	struct crypto_blkcipher *initiator_enc;
	struct crypto_blkcipher *acceptor_enc_aux;
	struct crypto_blkcipher *initiator_enc_aux;
	struct crypto_skcipher	*enc;
	struct crypto_skcipher	*seq;
	struct crypto_skcipher *acceptor_enc;
	struct crypto_skcipher *initiator_enc;
	struct crypto_skcipher *acceptor_enc_aux;
	struct crypto_skcipher *initiator_enc_aux;
	u8			Ksess[GSS_KRB5_MAX_KEYLEN]; /* session key */
	u8			cksum[GSS_KRB5_MAX_KEYLEN];
	s32			endtime;
@@ -262,24 +262,24 @@ gss_unwrap_kerberos(struct gss_ctx *ctx_id, int offset,


u32
krb5_encrypt(struct crypto_blkcipher *key,
krb5_encrypt(struct crypto_skcipher *key,
	     void *iv, void *in, void *out, int length);

u32
krb5_decrypt(struct crypto_blkcipher *key,
krb5_decrypt(struct crypto_skcipher *key,
	     void *iv, void *in, void *out, int length); 

int
gss_encrypt_xdr_buf(struct crypto_blkcipher *tfm, struct xdr_buf *outbuf,
gss_encrypt_xdr_buf(struct crypto_skcipher *tfm, struct xdr_buf *outbuf,
		    int offset, struct page **pages);

int
gss_decrypt_xdr_buf(struct crypto_blkcipher *tfm, struct xdr_buf *inbuf,
gss_decrypt_xdr_buf(struct crypto_skcipher *tfm, struct xdr_buf *inbuf,
		    int offset);

s32
krb5_make_seq_num(struct krb5_ctx *kctx,
		struct crypto_blkcipher *key,
		struct crypto_skcipher *key,
		int direction,
		u32 seqnum, unsigned char *cksum, unsigned char *buf);

@@ -320,12 +320,12 @@ gss_krb5_aes_decrypt(struct krb5_ctx *kctx, u32 offset,

int
krb5_rc4_setup_seq_key(struct krb5_ctx *kctx,
		       struct crypto_blkcipher *cipher,
		       struct crypto_skcipher *cipher,
		       unsigned char *cksum);

int
krb5_rc4_setup_enc_key(struct krb5_ctx *kctx,
		       struct crypto_blkcipher *cipher,
		       struct crypto_skcipher *cipher,
		       s32 seqnum);
void
gss_krb5_make_confounder(char *p, u32 conflen);
+215 −135

File changed.

Preview size limit exceeded, changes collapsed.

+6 −6
Original line number Diff line number Diff line
@@ -54,9 +54,9 @@
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

#include <crypto/skcipher.h>
#include <linux/err.h>
#include <linux/types.h>
#include <linux/crypto.h>
#include <linux/sunrpc/gss_krb5.h>
#include <linux/sunrpc/xdr.h>
#include <linux/lcm.h>
@@ -147,7 +147,7 @@ u32 krb5_derive_key(const struct gss_krb5_enctype *gk5e,
	size_t blocksize, keybytes, keylength, n;
	unsigned char *inblockdata, *outblockdata, *rawkey;
	struct xdr_netobj inblock, outblock;
	struct crypto_blkcipher *cipher;
	struct crypto_skcipher *cipher;
	u32 ret = EINVAL;

	blocksize = gk5e->blocksize;
@@ -157,11 +157,11 @@ u32 krb5_derive_key(const struct gss_krb5_enctype *gk5e,
	if ((inkey->len != keylength) || (outkey->len != keylength))
		goto err_return;

	cipher = crypto_alloc_blkcipher(gk5e->encrypt_name, 0,
	cipher = crypto_alloc_skcipher(gk5e->encrypt_name, 0,
				       CRYPTO_ALG_ASYNC);
	if (IS_ERR(cipher))
		goto err_return;
	if (crypto_blkcipher_setkey(cipher, inkey->data, inkey->len))
	if (crypto_skcipher_setkey(cipher, inkey->data, inkey->len))
		goto err_return;

	/* allocate and set up buffers */
@@ -238,7 +238,7 @@ u32 krb5_derive_key(const struct gss_krb5_enctype *gk5e,
	memset(inblockdata, 0, blocksize);
	kfree(inblockdata);
err_free_cipher:
	crypto_free_blkcipher(cipher);
	crypto_free_skcipher(cipher);
err_return:
	return ret;
}
+46 −43

File changed.

Preview size limit exceeded, changes collapsed.

+11 −11

File changed.

Preview size limit exceeded, changes collapsed.

Loading