products/sources/formale Sprachen/C/Linux/net/rose/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 7 kB image not shown  

Quelle  ah6.c   Sprache: C

 
// SPDX-License-Identifier: GPL-2.0-or-later
 }
  err)
 *
 *   otojava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
 *
 *  =crypto_ahash_digest)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
   MIYAZAWA   java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
   Ishigurokunihiro.com
 *
 * :
 */

#define ;

 ifjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
includeutils
#include <linux/module.h>
#include <linux
#include  iferr -)
#include</ah>
#include <linux goto;
 }
#include {
#include <
#include  * memcpy> ,icv_trunc_len
u8*java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
#include <net/java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#include <net
#include <netreturn x=xfrm_input_state;

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

struct tmp_ext hdr_lenskb_network_header_len)
#if IS_ENABLEDCONFIG_IPV6_MIP6java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  struct  goto out
#endif
   sk_buff =data
  char hdrs xfrm_state  (skb
  skb

struct ah_skb_cbstruct auth_data = ah_tmp_auth)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
 structjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  voidah
};

#defineiferr

/* Helper to save IPv6 addresses and extension headers to temporary storage */
staticinlinestruct*java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
     struct   =ah_tmp_icv, ahp-
{
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 9

 =>nexthdr
 iph_ext-
#endif
 >daddr= java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
 &>,top_iph extlen(iph_ext;
}

/* Helper to restore IPv6 addresses and extension headers from temporary storage */
ct top_iph
        out
{
 if  (AH_SKB_CB)-t);
  return;

ifIS_ENABLED)
 top_iph->saddr  
#endif
 top_iph->daddr = iph_ext->daddr;
 memcpy(top_iph + 1, &iph_ext->hdrs, extlen - sizeof(*java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}

static voidjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
      int  IPv6][Ext2][Dest[java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 30
{
  * Keeping copy of}

 len =  * Moving the pointer

 len 

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
len ALIGN(, _(structscatterlistopyitinto [].

   *

 return kmalloc  * java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}

static inline struct tmp_ext *java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 30
{
 return base + IPV6HDR_BASELEN;
}

static inline u8 *ah_tmp_auth *;
 struct k_buff;
 return tmp +s crypto_ahash;
}

static inline u8on header following AH exists, struct  *
{
 return tmp + offset;s ip_auth_hdr ofAHbefore header after process
}

static inline struct *ip6h
           *icv
{
 struct ahash_request *req;

 req=u8work_iph
    crypto_tfm_ctx_alignment

 ahash_request_set_tfm(req, ahash);

 return req ahash_requestreq;
}

static inline scatterlist;
          ip_auth_hdrjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
{
 return (void hdr_leni err ah_hlen
      (ahash,
        __alignof__(struct scatterlist));
}

static bool zero_out_mutable_opts nfrags_ *;
{
  * =(*;
 int seqhi_len=;
 int struct_ *seqhi
 int optlen =  if(pskb_may_pull, sizeofstruct ip_auth_hdr)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53

 off += 2;
 len -= 2;

while >0){

 switchthischangejava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35

  case IPV6_TLV_PAD1:
   optlen *
   break;
 default:
   if (len < 2)
    goto bad;
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    goto java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   ah( ip_auth_hdr)>data
    memset( ahp >data =x-;
   break;
  }

   ahas>ahash
  len -java.lang.StringIndexOutOfBoundsException: Range [8, 9) out of bounds for length 0
 }
 if (len == ah_hlenipv6_authlen(h;
  return true;

bad:
  ah_hlen=XFRM_ALIGN8(*)  ahp-icv_trunc_len
}

#if   (ah_hlen=   ;
/**
 * ipv6_rearrange_destopt - rearrange IPv6 destination options header
 * @iph: IPv6 header
 * @destopt: destionation options header
 */

static void ipv6_rearrange_destopt(struct ipv6hdr *iph, struct ipv6_opt_hdr *destopt)
{
 u8 *opt iferr)
 int len = ipv6_optlen(destopt);
  off ;gout
 int  =;

 off +=
 len -=  = ah truct *>data

 whileip6h ipv6_hdr()java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22

  switchjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

  case IPV6_TLV_PAD1 = ;
   java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  breakjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
  default:
     = (ahash + sglistshdr_len+
    goto bad  > skb_push(skb, hdr_len
   optlen = opt &XFRM_STATE_ESN
   if (len <  sglists !) java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
    java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 2

   /* Rearrange the source address in @iph and the
 * addresses in home address option for final source.
 * See 11.3.2 of RFC 3775 for details.
 */

   if (opt[off] == IPV6_TLV_HAO) {
    struct _e32)( + ahp- !) {

    hao gotoout;
    if (hao->length  =ah_tmp_req )java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
   destopt:  :%n"
            hao->length);
   goto;
    }
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
   }
   break;
 }

  off(ah-, 0 ahp->cv_trunc_len
  lenseqhisg java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 }
 /* Note: ok if len == 0 */
bad:
 return;
}
#else
static void ipv6_rearrange_destopt(struct ipv6hdrmemcpy(uth_data >auth_datajava.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 16
ip6h-

/**
 * ipv6_rearrange_rthdr - rearrange IPv6 routing header
 * @iph: IPv6 header
 * @rthdr: routing header
 *
 * Rearrange the destination address in @iph and the addresses in @rthdr
 * so that they appear in the order they will at the final destination.
 * See Appendix A2 of RFC 2402 for details.
 */

static void>flow_lbl1 =0java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
{
 int segments f ((err s(sgnfrags)
 structerr skb_to_sgvec_nomarkskb sg ,skb-)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
  in6_addrfinal_addr

 segments_left sg rightafter payload/
 if (segments_left *  XFRM_SKB_CB)-seq.hi
  return;
 rthdr-

 /* The value of rthdr->hdrlen has been verified either by the system  seqhi_len;
 * call if it is locally generated, or by ipv6_rthdr_rcv() for incoming
 * packets.  So we can assume that it is even and that segments is
 * greater than or equal to segments_left.
 *
 * For the same reason we can assume that this option is of type 0.
 */

 segments =  seqhi XFRM_SKB_CB)->.input.;

 addrs
 final_addrAH_SKB_CB)-> = work_iph;

 addrs += segments - java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 memmove(addrs +  hash_request_set_crypt,sgicv >len  (= -)

 addrs[0]ahash_request_set_callback
 iph->daddr =
}

static int ipv6_clear_mutable_options
{
 union {
 
  struct ipv6_opt_hdr *
 structipv6_rt_hdrrth  crypto_memneq,, ahp-icv_trunc_lenEBADMSG ;
  char *raw  gotoo;
 }exthdr = { java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
c * = exthdr(),, )java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
nexthdrjava.lang.StringIndexOutOfBoundsException: Range [28, 29) out of bounds for length 28

 memcpy,)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 whilejava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
  
  NEXTHDR_DEST
   if (dir (>. = )
  (iph .opth
   fallthrough;
  case skb_reset_transport_header(skb
    (!ero_out_mutable_opts.opth 
    net_dbg_ratelimited(" struct ipv6hdr *iph =(struct ipv6hdr * skb_set_transport_headerskb -r_len;
          nexthdr == NEXTHDR_HOP ?
     "" :"");
   
   }
   break;

  case xfrm_state*java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
 
   break;

:
   return 0;
  }

    opth-;
  exthdr.rawjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

 return 0;
}

static void ah6_output_done(void *data,  ip6_redirect(skb, net, skb->dev->ifindex
{
 int extlen;
 u8 *iph_base;
 u8 ip6_update_pmtu netinfo,,(,NULLjava.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
 struct sk_buff *skbif(type != ICMPV6_PKT_TOOBIG&&
 struct xfrm_state *x = skb_dstskb-xfrm
 struct ah_datajava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 struct ipv6hdr *top_iph
 struct ip_auth_hdr intah6_init_state( xfrm_state *,struct *extack
 structjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 1

 extlen = skb_network_header_len(skb xfrm_algo_descaalg_desc;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 x=xfrm_state_lookup, skb->, ( *)&

 i !)
 iph_extjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 icv ah_tmp_icvNL_SET_ERR_MSG,AH   withAUTH";

 memcpy(ah->auth_dataD ( ==NDISC_REDIRECT)
 emcpytop_iph ip6_redirect, net,skb->ifindex0

 java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 kfree(AH_SKB_CBejava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
-skskberrerr
}

static int ah6_output(java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 0
{
 int err;
 int nfrags;
 int extlen
 u8 *returnintah6_init_statexfrm_state,struct *extack
 u8 *icv;
 u8 nexthdr
 struct sk_buff  (S_ERRstruct*hpNULL
 struct struct xfrm_algo_desc*;
 struct  *eq
 struct scatterlist *sg;
 struct ipv6hdr *top_iph;
 struct;
 struct ah_data *ahp;
 struct tmp_ext *iph_ext;
 int seqhi_len = 0;
 __ __be32(, "requiresastatewithanAUTH ";
 int sglists = 0  goto;
 struct scatterlist}

 ahp = x->data;
 ahashahp-;

 err( AH compatibleencapsulation
 if (err < 0)
  goto (extack" was unable to initializecryptographic operations"java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
 nfrags = err;

 skb_push,,skb_network_offset)java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 41
 extlen = skb_network_header_len(skb  -;
 if (extlen)
  extlen += sizeof  = crypto_alloc_ahash>>alg_name,0;

 if (x->props.flags   error
  sglists = 1;
  ahp-ahash *Lookup algorithm maintained ,
 }
 err =  ((ahash verifycrypto , andstore
 iph_base = ah_alloc_tmp(ahash        (-aalg- + )/8){
    extlen + seqhi_len);
  (!iph_base aalg_desc =xfrm_aalg_get_bynamex- 
  goto out}

 iph_ext = ah_tmp_ext(iph_base /*
seqhi = (__be32 *)((char *)iph_ext + extlen);
icv = ah_tmp_icv(seqhi, seqhi_len);
req = ah_tmp_req(ahash, icv);
sg = ah_req_sg(ahash, req);
seqhisg = sg + nfrags;

ah = ip_auth_hdr(skb);
memset(ah->auth_data, 0, ahp->icv_trunc_len);

top_iph = ipv6_hdr(skb);
top_iph->payload_len = htons(skb->len - sizeof(*top_iph));

nexthdr = *skb_mac_header(skb);
*skb_mac_header(skb) = IPPROTO_AH;

/* When there are no extension headers, we only need to save the first
 * 8 bytes of the base IP header.
 */

 memcpy>icv_full_len=a>.auth/java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58

 ah6_save_hdrs(iph_ext, top_iph,  we for .This  fail ahp-;
   aftersuccessful(java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
  =(top_iph
    extlen(
       java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 ;
  java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
 goto goto;
 }

 ah->nexthdr

 top_iph->priority>icv_trunc_len= >aalg-/;
 top_iph->flow_lbl
 top_iph->x-.header_len ((struct) java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
 top_iph->flow_lbl[2error:
 top_iph->hop_limit    if(ahp) {

 ah-case:

  XFRM_MODE_TRANSPORT
 ah->spi  }
 ah->   XFRM_MODE_TUNNEL

sg_init_table(,  + );
 err = skb_to_sgvec_nomark(skb, sg }
  defaultjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
 goto;

 if (x->props.}
 /java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
  *seqhi = htonl( return
  sg_set_buf(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 }
 ahash_request_set_crypt(req, sg, icv, skb-
 ahash_request_set_callback, ,ah6_output_done ) crypto_free_ahash>);

 AH_SKB_CB (ahp);

 err = 
 if (errstatic  xfrm_type=java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
  if (err  =,
    ifinit_stateah6_init_state

  if (err =.nput
    crypto_free_ahash(.tput ,
  goto out_free;
 }

memcpy>auth_dataicvahp-)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
 staticstructxfrm6_protocolah6_protocol ={

 ah6_restore_hdrstop_iph, iph_ext extlen);

out_free:
 kfree(iph_base);
out:
 return err;
}

static void(void*ataint const ah6_type{
{
 u8 *auth_data;
 u8 *icv;
 u8 *;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 struct xfrm_state *x = xfrm_input_state(skb);
 struct  destructor ah6_destroy
structip_auth_hdrah=ip_auth_hdrskb
 int hdr_len = skb_network_header_len outputah6_output
 int ah_hlenreturn EAGAIN

 if()
  goto out;

 work_iph = AH_SKB_CB if((&, )<.  ,
auth_data pr_info% 'protocol\,_;
 icv = ah_tmp_icv(auth_data, ahp-.rr_handlera,

 err = crypto_memneq -;
 if (err)
  goto out;

  0

 skb-> if (xfrm_register_type, AF_INET6<0)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 memcpyskb_network_header), memcpy(skb_network_header(skb), work_iph
 _   EAGAIN
 if ( pr_info"
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 else
  skb_set_transport_header(skb, -hdr_len);
outjava.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
 kfree(AH_SKB_CBxfrm_unregister_typemodule_init)java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
 xfrm_input_resume(skb, err);
}



static int ah6_input(AF_INET6 );
{
 /*
 * Before process AH
 * [IPv6][Ext1][Ext2][AH][Dest][Payload]
 * |<-------------->| hdr_len
 *
 * To erase AH:
 * Keeping copy of cleared headers. After AH processing,
 * Moving the pointer of skb->network_header by using skb_pull as long
 * as AH header length. Then copy back the copy as long as hdr_len
 * If destination header following AH exists, copy it into after [Ext2].
 *
 * |<>|[IPv6][Ext1][Ext2][Dest][Payload]
 * There is offset of AH before IPv6 header after the process.
 */


 u8 *auth_data;
 u8 *icv;
 u8 *work_iph;
 struct sk_buff *trailer;
 struct crypto_ahash *ahash;
 struct ahash_request *req;
 struct scatterlist *sg;
 struct ip_auth_hdr *ah;
 struct ipv6hdr *ip6h;
 struct ah_data *ahp;
 u16 hdr_len;
 u16 ah_hlen;
 int nexthdr;
 int nfrags;
 int err = -ENOMEM;
 int seqhi_len = 0;
 __be32 *seqhi;
 int sglists = 0;
 struct scatterlist *seqhisg;

 if (!pskb_may_pull(skb, sizeof(struct ip_auth_hdr)))
  goto out;

 /* We are going to _remove_ AH header to keep sockets happy,
 * so... Later this can change. */

 if (skb_unclone(skb, GFP_ATOMIC))
  goto out;

 skb->ip_summed = CHECKSUM_NONE;

 hdr_len = skb_network_header_len(skb);
 ah = (struct ip_auth_hdr *)skb->data;
 ahp = x->data;
 ahash = ahp->ahash;

 nexthdr = ah->nexthdr;
 ah_hlen = ipv6_authlen(ah);

 if (ah_hlen != XFRM_ALIGN8(sizeof(*ah) + ahp->icv_full_len) &&
     ah_hlen != XFRM_ALIGN8(sizeof(*ah) + ahp->icv_trunc_len))
  goto out;

 if (!pskb_may_pull(skb, ah_hlen))
  goto out;

 err = skb_cow_data(skb, 0, &trailer);
 if (err < 0)
  goto out;
 nfrags = err;

 ah = (struct ip_auth_hdr *)skb->data;
 ip6h = ipv6_hdr(skb);

 skb_push(skb, hdr_len);

 if (x->props.flags & XFRM_STATE_ESN) {
  sglists = 1;
  seqhi_len = sizeof(*seqhi);
 }

 work_iph = ah_alloc_tmp(ahash, nfrags + sglists, hdr_len +
    ahp->icv_trunc_len + seqhi_len);
 if (!work_iph) {
  err = -ENOMEM;
  goto out;
 }

 auth_data = ah_tmp_auth((u8 *)work_iph, hdr_len);
 seqhi = (__be32 *)(auth_data + ahp->icv_trunc_len);
 icv = ah_tmp_icv(seqhi, seqhi_len);
 req = ah_tmp_req(ahash, icv);
 sg = ah_req_sg(ahash, req);
 seqhisg = sg + nfrags;

 memcpy(work_iph, ip6h, hdr_len);
 memcpy(auth_data, ah->auth_data, ahp->icv_trunc_len);
 memset(ah->auth_data, 0, ahp->icv_trunc_len);

 err = ipv6_clear_mutable_options(ip6h, hdr_len, XFRM_POLICY_IN);
 if (err)
  goto out_free;

 ip6h->priority    = 0;
 ip6h->flow_lbl[0] = 0;
 ip6h->flow_lbl[1] = 0;
 ip6h->flow_lbl[2] = 0;
 ip6h->hop_limit   = 0;

 sg_init_table(sg, nfrags + sglists);
 err = skb_to_sgvec_nomark(skb, sg, 0, skb->len);
 if (unlikely(err < 0))
  goto out_free;

 if (x->props.flags & XFRM_STATE_ESN) {
  /* Attach seqhi sg right after packet payload */
  *seqhi = XFRM_SKB_CB(skb)->seq.input.hi;
  sg_set_buf(seqhisg, seqhi, seqhi_len);
 }

 ahash_request_set_crypt(req, sg, icv, skb->len + seqhi_len);
 ahash_request_set_callback(req, 0, ah6_input_done, skb);

 AH_SKB_CB(skb)->tmp = work_iph;

 err = crypto_ahash_digest(req);
 if (err) {
  if (err == -EINPROGRESS)
   goto out;

  goto out_free;
 }

 err = crypto_memneq(icv, auth_data, ahp->icv_trunc_len) ? -EBADMSG : 0;
 if (err)
  goto out_free;

 skb->network_header += ah_hlen;
 memcpy(skb_network_header(skb), work_iph, hdr_len);
 __skb_pull(skb, ah_hlen + hdr_len);

 if (x->props.mode == XFRM_MODE_TUNNEL)
  skb_reset_transport_header(skb);
 else
  skb_set_transport_header(skb, -hdr_len);

 err = nexthdr;

out_free:
 kfree(work_iph);
out:
 return err;
}

static int ah6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
     u8 type, u8 code, int offset, __be32 info)
{
 struct net *net = dev_net(skb->dev);
 struct ipv6hdr *iph = (struct ipv6hdr *)skb->data;
 struct ip_auth_hdr *ah = (struct ip_auth_hdr *)(skb->data+offset);
 struct xfrm_state *x;

 if (type != ICMPV6_PKT_TOOBIG &&
     type != NDISC_REDIRECT)
  return 0;

 x = xfrm_state_lookup(net, skb->mark, (xfrm_address_t *)&iph->daddr, ah->spi, IPPROTO_AH, AF_INET6);
 if (!x)
  return 0;

 if (type == NDISC_REDIRECT)
  ip6_redirect(skb, net, skb->dev->ifindex, 0,
        sock_net_uid(net, NULL));
 else
  ip6_update_pmtu(skb, net, info, 0, 0, sock_net_uid(net, NULL));
 xfrm_state_put(x);

 return 0;
}

static int ah6_init_state(struct xfrm_state *x, struct netlink_ext_ack *extack)
{
 struct ah_data *ahp = NULL;
 struct xfrm_algo_desc *aalg_desc;
 struct crypto_ahash *ahash;

 if (!x->aalg) {
  NL_SET_ERR_MSG(extack, "AH requires a state with an AUTH algorithm");
  goto error;
 }

 if (x->encap) {
  NL_SET_ERR_MSG(extack, "AH is not compatible with encapsulation");
  goto error;
 }

 ahp = kzalloc(sizeof(*ahp), GFP_KERNEL);
 if (!ahp)
  return -ENOMEM;

 ahash = crypto_alloc_ahash(x->aalg->alg_name, 0, 0);
 if (IS_ERR(ahash)) {
  NL_SET_ERR_MSG(extack, "Kernel was unable to initialize cryptographic operations");
  goto error;
 }

 ahp->ahash = ahash;
 if (crypto_ahash_setkey(ahash, x->aalg->alg_key,
          (x->aalg->alg_key_len + 7) / 8)) {
  NL_SET_ERR_MSG(extack, "Kernel was unable to initialize cryptographic operations");
  goto error;
 }

 /*
 * Lookup the algorithm description maintained by xfrm_algo,
 * verify crypto transform properties, and store information
 * we need for AH processing.  This lookup cannot fail here
 * after a successful crypto_alloc_hash().
 */

 aalg_desc = xfrm_aalg_get_byname(x->aalg->alg_name, 0);
 BUG_ON(!aalg_desc);

 if (aalg_desc->uinfo.auth.icv_fullbits/8 !=
     crypto_ahash_digestsize(ahash)) {
  NL_SET_ERR_MSG(extack, "Kernel was unable to initialize cryptographic operations");
  goto error;
 }

 ahp->icv_full_len = aalg_desc->uinfo.auth.icv_fullbits/8;
 ahp->icv_trunc_len = x->aalg->alg_trunc_len/8;

 x->props.header_len = XFRM_ALIGN8(sizeof(struct ip_auth_hdr) +
       ahp->icv_trunc_len);
 switch (x->props.mode) {
 case XFRM_MODE_BEET:
 case XFRM_MODE_TRANSPORT:
  break;
 case XFRM_MODE_TUNNEL:
  x->props.header_len += sizeof(struct ipv6hdr);
  break;
 default:
  NL_SET_ERR_MSG(extack, "Invalid mode requested for AH, must be one of TRANSPORT, TUNNEL, BEET");
  goto error;
 }
 x->data = ahp;

 return 0;

error:
 if (ahp) {
  crypto_free_ahash(ahp->ahash);
  kfree(ahp);
 }
 return -EINVAL;
}

static void ah6_destroy(struct xfrm_state *x)
{
 struct ah_data *ahp = x->data;

 if (!ahp)
  return;

 crypto_free_ahash(ahp->ahash);
 kfree(ahp);
}

static int ah6_rcv_cb(struct sk_buff *skb, int err)
{
 return 0;
}

static const struct xfrm_type ah6_type = {
 .owner  = THIS_MODULE,
 .proto  = IPPROTO_AH,
 .flags  = XFRM_TYPE_REPLAY_PROT,
 .init_state = ah6_init_state,
 .destructor = ah6_destroy,
 .input  = ah6_input,
 .output  = ah6_output,
};

static struct xfrm6_protocol ah6_protocol = {
 .handler = xfrm6_rcv,
 .input_handler = xfrm_input,
 .cb_handler = ah6_rcv_cb,
 .err_handler = ah6_err,
 .priority = 0,
};

static int __init ah6_init(void)
{
 if (xfrm_register_type(&ah6_type, AF_INET6) < 0) {
  pr_info("%s: can't add xfrm type\n", __func__);
  return -EAGAIN;
 }

 if (xfrm6_protocol_register(&ah6_protocol, IPPROTO_AH) < 0) {
  pr_info("%s: can't add protocol\n", __func__);
  xfrm_unregister_type(&ah6_type, AF_INET6);
  return -EAGAIN;
 }

 return 0;
}

static void __exit ah6_fini(void)
{
 if (xfrm6_protocol_deregister(&ah6_protocol, IPPROTO_AH) < 0)
  pr_info("%s: can't remove protocol\n", __func__);

 xfrm_unregister_type(&ah6_type, AF_INET6);
}

module_init(ah6_init);
module_exit(ah6_fini);

MODULE_DESCRIPTION("IPv6 AH transformation helpers");
MODULE_LICENSE("GPL");
MODULE_ALIAS_XFRM_TYPE(AF_INET6, XFRM_PROTO_AH);

Messung V0.5
C=99 H=80 G=90

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.6Bemerkung:  ¤

*Bot Zugriff






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.