···3131#define __sctp_auth_h__32323333#include <linux/list.h>3434-#include <linux/crypto.h>35343635struct sctp_endpoint;3736struct sctp_association;3837struct sctp_authkey;3938struct sctp_hmacalgo;3939+struct crypto_shash;40404141/*4242 * Define a generic struct that will hold all the info···9090 struct sctp_association *asoc,9191 gfp_t gfp);9292int sctp_auth_init_hmacs(struct sctp_endpoint *ep, gfp_t gfp);9393-void sctp_auth_destroy_hmacs(struct crypto_hash *auth_hmacs[]);9393+void sctp_auth_destroy_hmacs(struct crypto_shash *auth_hmacs[]);9494struct sctp_hmac *sctp_auth_get_hmac(__u16 hmac_id);9595struct sctp_hmac *sctp_auth_asoc_get_hmac(const struct sctp_association *asoc);9696void sctp_auth_asoc_set_default_hmac(struct sctp_association *asoc,
+3-3
include/net/sctp/structs.h
···8282struct sctp_ulpq;8383struct sctp_ep_common;8484struct sctp_ssnmap;8585-struct crypto_hash;8585+struct crypto_shash;868687878888#include <net/sctp/tsnmap.h>···166166 struct sctp_pf *pf;167167168168 /* Access to HMAC transform. */169169- struct crypto_hash *hmac;169169+ struct crypto_shash *hmac;170170 char *sctp_hmac_alg;171171172172 /* What is our base endpointer? */···12351235 /* SCTP AUTH: array of the HMACs that will be allocated12361236 * we need this per association so that we don't serialize12371237 */12381238- struct crypto_hash **auth_hmacs;12381238+ struct crypto_shash **auth_hmacs;1239123912401240 /* SCTP-AUTH: hmacs for the endpoint encoded into parameter */12411241 struct sctp_hmac_algo_param *auth_hmacs_list;
+19-17
net/sctp/auth.c
···2727 * Vlad Yasevich <vladislav.yasevich@hp.com>2828 */29293030+#include <crypto/hash.h>3031#include <linux/slab.h>3132#include <linux/types.h>3232-#include <linux/crypto.h>3333#include <linux/scatterlist.h>3434#include <net/sctp/sctp.h>3535#include <net/sctp/auth.h>···448448 */449449int sctp_auth_init_hmacs(struct sctp_endpoint *ep, gfp_t gfp)450450{451451- struct crypto_hash *tfm = NULL;451451+ struct crypto_shash *tfm = NULL;452452 __u16 id;453453454454 /* If AUTH extension is disabled, we are done */···462462 return 0;463463464464 /* Allocated the array of pointers to transorms */465465- ep->auth_hmacs = kzalloc(466466- sizeof(struct crypto_hash *) * SCTP_AUTH_NUM_HMACS,467467- gfp);465465+ ep->auth_hmacs = kzalloc(sizeof(struct crypto_shash *) *466466+ SCTP_AUTH_NUM_HMACS, gfp);468467 if (!ep->auth_hmacs)469468 return -ENOMEM;470469···482483 continue;483484484485 /* Allocate the ID */485485- tfm = crypto_alloc_hash(sctp_hmac_list[id].hmac_name, 0,486486- CRYPTO_ALG_ASYNC);486486+ tfm = crypto_alloc_shash(sctp_hmac_list[id].hmac_name, 0, 0);487487 if (IS_ERR(tfm))488488 goto out_err;489489···498500}499501500502/* Destroy the hmac tfm array */501501-void sctp_auth_destroy_hmacs(struct crypto_hash *auth_hmacs[])503503+void sctp_auth_destroy_hmacs(struct crypto_shash *auth_hmacs[])502504{503505 int i;504506···506508 return;507509508510 for (i = 0; i < SCTP_AUTH_NUM_HMACS; i++) {509509- if (auth_hmacs[i])510510- crypto_free_hash(auth_hmacs[i]);511511+ crypto_free_shash(auth_hmacs[i]);511512 }512513 kfree(auth_hmacs);513514}···706709 struct sctp_auth_chunk *auth,707710 gfp_t gfp)708711{709709- struct scatterlist sg;710710- struct hash_desc desc;712712+ struct crypto_shash *tfm;711713 struct sctp_auth_bytes *asoc_key;712714 __u16 key_id, hmac_id;713715 __u8 *digest;···738742739743 /* set up scatter list */740744 end = skb_tail_pointer(skb);741741- sg_init_one(&sg, auth, end - (unsigned char *)auth);742745743743- desc.tfm = asoc->ep->auth_hmacs[hmac_id];744744- desc.flags = 0;746746+ tfm = asoc->ep->auth_hmacs[hmac_id];745747746748 digest = auth->auth_hdr.hmac;747747- if (crypto_hash_setkey(desc.tfm, &asoc_key->data[0], asoc_key->len))749749+ if (crypto_shash_setkey(tfm, &asoc_key->data[0], asoc_key->len))748750 goto free;749751750750- crypto_hash_digest(&desc, &sg, sg.length, digest);752752+ {753753+ SHASH_DESC_ON_STACK(desc, tfm);754754+755755+ desc->tfm = tfm;756756+ desc->flags = 0;757757+ crypto_shash_digest(desc, (u8 *)auth,758758+ end - (unsigned char *)auth, digest);759759+ shash_desc_zero(desc);760760+ }751761752762free:753763 if (free_key)