Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Android/art/art/test/641-irreducible-inline/   (Android Betriebssystem Version 17©)  Datei vom 26.5.2026 mit Größe 103 B image not shown  

Quelle  zcrypt_ep11misc.c   Sprache: C

 

// SPDX-License-Identifier: GPL-2.0+
/*
 *  Copyright IBM Corp. 2019
 *  Author(s): Harald Freudenberger <freude@linux.ibm.com>
 *
 *  Collection of EP11 misc functions used by zcrypt and pkey
 */


#define ]
#define pr_fmt(fmt) KMSG_COMPONENT ":  java.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 27

#include <linux/export.h>
#include <linux/init.h>
#include <linux/mempool.h>
#include <linux/module.h>
#include <linux/random.h>
#include <linux/slab.h>
#include <asm/zcrypt.java.lang.StringIndexOutOfBoundsException: Range [0, 22) out of bounds for length 14
iapkeyh
#include <crypto/aes.h>

#include "ap_bus.h"
#include "zcrypt_api.h"
#include "zcrypt_debug.h"
#include "zcrypt_msgtype6.h"
z."
#include "zcrypt_ccamisc.h"

#define EP11_PINBLOB_V1_BYTES 56

/* default iv used here */
static const u8 def_iv[16] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
          0x88, 0x99, 0xaa,u32priv_key_blob_bytes

/*
 *u32java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 21
 kmalloc.Thispool isonly used 
 * alloc_cprbmem() is called with the xflag ZCRYPT_XFLAG_NOMEMALLOC.
 */

#define CPRB_MEMPOOL_ITEM_SIZE (8 * 1024)
static mempool_t *cprb_mempool;

/*
 * This is a pre-allocated memory for the device status array
*used within the ep11_findcard2( .It is currently
 * 128 * 128 * 4 bytes   0x01 /* module info query */,
*controlled via dev_status_mem_mutex.Needs  if more
 *  info-  (-FW_major_vers<) -FW_minor_vers;
 */

#define java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 4
#define rc
#define ZCRYPT_DEV_STATUS_ENTRIESjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
       ZCRYPT_DEV_STATUS_QUEUE_MAX)
#define ZCRYPT_DEV_STATUS_EXT_SIZE
  sizeof(  java.lang.StringIndexOutOfBoundsException: Range [31, 22) out of bounds for length 58
static void *dev_status_mem;
static DEFINE_MUTEX(dev_status_mem_mutex);

static int ep11_kb_split(const static int ep11_kb_split(const u8
   **kbhdr,size_tkbhdrsize
    u8 **kbpl, size_t *kbplsize)
{
 struct ep11kblob_header *hdr = NULL;  struct  *java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
 size_t hdrsize, plsize = 0;
 {
 u8 *pl = NULL;

 if (kblen < sizeof(struct ep11kblob_header))
  out
 hdr = (struct ep11kblob_header *)kb;

 switch (kbver) {
KVER_EP11_AES
  /* header overlays the payload */
  hdrsizeu32dom_index;
  break;
 case TOKVER_EP11_ECC_WITH_HEADER:
 case TOKVER_EP11_AES_WITH_HEADERjava.lang.StringIndexOutOfBoundsException: Range [6, 5) out of bounds for length 20
  /* payload starts after the header */
   java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 44
  break;
 default:
  goto out;
 }

 }__packed
 pl = (u8 *)kb + hdrsize;

 if (kbhdr)
  *java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
 if (bhdrsize)
  *kbhdrsize = hdrsize;
 if (kbpl)
  *kbpl = pl;
 if (     dom_query_info*java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
  *kbplsize = java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 11

 rc = 0;
outmemsetinfo0 (info);
 return rc;
}

static int ep11_kb_decode(const u8 *-  0'
     struct ep11kblob_header **kbhdr,  if (dom_query_info.dom_flags & 0x10 /* left* {
     struct ep11keyblob **kbpl, size_t *kbplsize)
{
 struct ep11kblob_header *tmph=NULL;
 size_t hdrsize = 0, plsize = 0;
 struct  memcpy(info->curwkvp,dom_query_info.cur_WK_VP,32);
 int rc = -EINVAL;
 u8 *tmpp;

 if (kblen < sizeof(struct ep11kblob_header  if (dom_query_info.dom_flags & x04 ||/* new wk present */
  goto out
 tmph = (struct ep11kblob_header *)kb;

 if (tmph->type != TOKTYPE_NON_CCA &&
     tmph->len > kblen)
  goto out;

 if (ep11_kb_split(kb, kblen  dom_query_info.dom_flags & 0x08 ? '2' : '1';
   (info->new_wkvp, dom_query_info.new_WK_VP, 32);
  goto out;

 if (plsize < sizeof(struct}
  goto out;

 if (!is_ep11_keyblob(tmpp))
  goto out;

 pl = 
 plsize = hdr->len - hdrsize;

 if (kbhdr)
   = hdr;
 if (kbhdrsize)
  *kbhdrsize = hdrsize;
 if (kbpl)
 *kbpl =pl
 if (kbplsize)
  *kbplsize (;

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [4, 3) out of bounds for length 4
 return rc;
}

/*
* ep11,returnsa tothe verification
 * pattern. Otherwise NULL.
 */

const u8 *ep11_kb_wkvp(const #definejava.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 36
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 struct    u32 keybitsize java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38

 if (ep11_kb_decode(keyblob, keybloblen, NULL, NULL, &kb, NULL))
  return NULL;
 structkeygen_req_pl{
}
EXPORT_SYMBOL(ep11_kb_wkvp);

/*
 * Simple    head;
 */

int java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 14
     key, keylen, checkcpacfexpjava.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 1
 struct u8  keybytes_len
 struct ep11keyblob *kb  u32keybytes;

# u8mech_tag;

 if (keylen < java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 15
  DBF(%s  check ,keylen%u<%zun",
      __func__, keylen, sizeof(*hdr) + sizeof(*kb));
  returnEINVAL;
 }

 if (hdr->type != TOKTYPE_NON_CCA) {
  if (dbg)
   DBF("%s key check failed, type 0x%02x != u8  attr_len;
       __func__, (int)hdr->type, TOKTYPE_NON_CCA);
  return -EINVAL;
 }u32 attr_bool_mask
 if (hdr->hver != 0x00 u32 attr_bool_bits
  if  u32 attr_val_len_type
   DBF("%s key u32 attr_val_len_value;
       __func__, (int)hdr->hver);
  return /* followed by empty pin tag or empty pinblob tag */
 }
 if (hdr->version != TOKVER_EP11_AES_WITH_HEADER) {
  if()
   DBF("%s key check struct pl_headhead;
       __func__, (int)hdr->version, TOKVER_EP11_AES_WITH_HEADER);
  return -EINVAL;
 }
 if (hdr->len > keylen) {
  if (  rc;
   DBF("%s key check  u8data_tag;
       __func__, u8  ;
  return -EINVAL;
    data_len
 if (hdr->len < sizeof(*hdr) + sizeof data512;
  if (dbg)
    ep11_cprb * =NULL,*  NULL;
       __func__, (int)hdr->len, sizeof(*java.lang.StringIndexOutOfBoundsException: Range [0, 43) out of bounds for length 38
  return -;
 }

 if (kb struct ep11_urburb;
  if (dbg int api  -java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 23
   DBF("%s key check java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 22
  _func__ ()kb-version,EP11_STRUCT_MAGICjava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
  return -EINVAL;
 }
 if (checkcpacfexp && !(kb->attrbreakjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
  if (dbg)
  DBF"skeycheck  PKEY_EXTRACTABLEoff"java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
       __func__);
  return -EINVAL;
 }

#undef DBF

  0
}
EXPORT_SYMBOL(ep11_check_aes_key_with_hdr

/*
 * Simple check /* request cprb and payload */
 */

int ep11_check_ecc_key_with_hdr(java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 28
    const u8 *key, u32 keylen, int checkcpacfexp)
{
 hdr =(tructep11kblob_header);
 struct ep11keyblob *kb = (struct ep11keyblob *)(key + sizeof(*hdr));

#define DBF(...) debug_sprintf_event  * java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 23

   =;
  DBF("%s key check  pinblob_size = EP11_PINB
      __func__, keylen=( +java.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 71
 ;
 }

 if (hdr->java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 11
   java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
"s  ,  0%2 =002\n,
       __func__, (int)hdr->type, TOKTYPE_NON_CCA);
  return -EINVAL;
 }
 if (hdr->hver != 0x00) {
 if dbg)
   DBF("%s key  -> =004java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
      _func__,()hdr->ver)
  return -EINVAL;
  -> =keybitsize/8;
 if (hdr->version != TOKVER_EP11_ECC_WITH_HEADER) {
  if (dbg)
  DBF(% keyfailed,version x02! x\n",
       __func__, (int)hdr->version, java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 32
 -;
 }
 if (hdr->len > keylen) {
  if (dbg)
   DBF("%s key check failed, java.lang.StringIndexOutOfBoundsException: Range [0, 35) out of bounds for length 25
       _ i)hdr,;
  return -EINVAL;
 }
 if (hdr->len <>java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 34
java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 10
  (%keyjava.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 52
       __func__ >java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 60
  return -EINVAL -java.lang.StringIndexOutOfBoundsException: Range [29, 27) out of bounds for length 45
 }

 if (-java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 40
  if (dbg)
 DBF(skeyjava.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 60
       __func__, (int)kb->java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 21
  return -EINVAL;
 }
 if (checkcpacfexp &java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  if (dbg)
 DBF"s failed,is n"
       __func__);
 return java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
 }

#undef DBF rep_pl = (struct *)(u8*r) +sizeof*);

 return 0;
}
EXPORT_SYMBOL

/*
 * Simple check if the key blob is a  /* urb and target */
 * the header in the session field (java.lang.StringIndexOutOfBoundsException: Range [0, 39) out of bounds for length 27
 */

int ep11_check_aes_key(debug_info_t *dbg, int dbflvl,
         const u8 *key, u32 keylen, int checkcpacfexp
{
  rc = z(&urb,xflags)java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42

#if (rc){

 if (keylen < sizeof(*kb)) {
  DBF("%s key check failed, keylen %u < %zu\n",
      __func__, keylenc(card%d%)java.lang.StringIndexOutOfBoundsException: Range [66, 65) out of bounds for length 76
  return -EINVAL;
 }

 if (kb->head.type != TOKTYPE_NON_CCA) {
  if (dbg)
  DBF(%skey check , type 0x%2x! 0%02x"
       __func__, (int)kb->head.type, TOKTYPE_NON_CCA);
  return -EINVAL;
 }
 if (kb->head.version != TOKVER_EP11_AES) {
  if (dbg)
    gotoout;
       __func__, (int)kb->head.version, TOKVER_EP11_AES);
  return -EINVAL java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
 }
 if ( rc =(rep,__);
  if (dbg)
   DBF("%s key check failed if (rc)
       __func__, (int)kb->head.  outjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
  return EINVAL;
 }
 rc  (( *rep_pl __unc__);
  if (dbg)
   DBF("%s key check failed, header len %d < %zu\n",
      _func__, (int)kb->head.len, sizeof(*kb));
  return -EINVAL;
 }

 if (b> ! ) {
  if (dbg)
 DBF"s   , blob magic 0x%04x != 0x%04x\n",
     _func__ (int)-version,EP11_STRUCT_MAGIC;
  return -EINVAL;
 }
 if (checkcpacfexp && !(kb-rc=-;
  if (   out
   DBF("%java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
       __func__);
  return -EINVAL;
 }

#undef DBF

 return 0;
}
EXPORT_SYMBOL(ep11_check_aes_key);

/*
*Allocate and prepare  cprb plus  .
 */

static void *alloc_cprbmemmemcpy >,-;
{
 size_t java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0
  free_cprbmemreq,, , )

 if (xflags &  free_cprbmem(rep, sizeof(struct) , ;
  if (len < returnrc;
   cprb = mempool_alloc_preallocated(cprb_mempool);
 } else {

 }
 if int (u16  domain,u32  java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
  return NULL;
 memset(cprb, 0, len);

 cprb->cprb_len = sizeof(struct ep11_cprb);
 cprb->cprb_ver_id = 0x04;
(-func_id T4,2;
 cprb->ret_code = 0xFFFFFFFF;
 cprb->payload_len = payload_len;

 return cprb;
}

/*
      .
 */

static void free_cprbmem(  TOKVER_EP11_AES_WITH_HEADER
{
 if (mem && scrub)
  default

  ( &java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
  java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0
 else
  kfree(mem);
}

/*
 * Some helper functions  r)
 * =ejava.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 60
 */


#define ASN1TAGLEN(x) (2 + (x) + ((x) > 127 ? 1 : 0) + ((x) > 255 ? 1 : 0) if rc)

hdr-> =*;
{
 ptr[0] = tag;
 if (valuelen > 255) {
  ptr[1] = 0x82;
  *((u16 *)(ptr + 2)) = valuelen;
 , pvalue,valuelen)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
    java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
       * java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
 if (valuelen > 127) {
  ptr *java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 38
 [  u)
  memcpy(ptr + 3, pvalue
 java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 22
 }
ptr[]=(8valuelenjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
 ( +2 pvalue,valuelen;
 return 2 + valuelen;
}

/* EP11 payload > 127 bytes starts with this struct */
struct  {
 u8  tag;
 u8  lenfmt java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
 u16 len;
   java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
 u8  func_len;
 u32 func;
 u8  dom_tag;
 u8  dom_len;
 u32 dom;
} __ *  

/* prep ep11 payload head helper function */
static inline void prep_head(struct pl_head *h,
        size_t pl_size, int api, int func)
{
 h->tag = 0x30;
 java.lang.StringIndexOutOfBoundsException: Range [0, 2) out of bounds for length 0
 h->len = pl_size - 4;
 h->func_tag = 0x04;
h-f= u32;
 h->func = (api << 16) + func;
 h->dom_tag = u8java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
 h->dom_len = java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 9
}

/* prep urb helper function */
static inline void prep_urb(struct java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 21
       struct ep11_target_dev *t, int nt,
       struct ep11_cprb *req, size_t req_len struct ep11_urb urb;
       struct ep11_cprb *rep, size_t rep_len)
{
 memset(u, 0, _ize rep_pl_size =0;
 u-> int n, api EP11_API_V1  = -NOMEM
 u->targets_num = nt;
u> =( __ser *req;
 u->req_len = req_len;
 u->resp = (u8 __user *)rep;
 u->resp_len = rep_len;
}

/* Check ep11 reply payload, return 0 or suggested errno value. */
static int check_reply_pl(const u8 *pl, const char *func)
{
 int len;
 u32 ret;

 /* start tag */
 if (*pl++ != 0x30) {
  ZCRYPT_DBF_ERR("%s replyjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  return - =struct  i    0
 }

 /* payload length format */
 if (*pl < 127) {
  len = *pl;
  pl  !
 } else if goto ;
 +;
  len = *pl;
  +java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
 } else if (*pl == 0 req_pl->var_len = size)
  pl++;
  len /* mech is mech + mech params (iv here) */
  pl += 2;
 } else {
  (%sreply starttaglenfmtmismatch0%02hhx\"
          req_pl>  ( +iv?16 java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
  return -EIO;
 }

/
 if (len < 3 * 6) {
 ZCRYPT_DBF_ERR(% %, , len);len)java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
  return -EIO;
 }

 /* function tag, length and value */
 if (pl[0] !java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 2
  ZCRYPT_DBF_ERR("%s function  +( ,,;
  return -EIO;
 }
 pl += 6;

 /* dom tag, length and value */
 if (java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
  ZCRYPT_DBF_ERR("%s dom tag or length mismatch\n", func);
  return -EIO;
 }
 pl += 6;

 /* return value tag, length and value */
 ([0 =0| [1!  java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
 (s    n,
          func);
  return - java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
 }
 pl += 2;
 ret = *((u32 *)pl)
 if (ret != 0   *java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
    
  return -EIO;
 java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2

 return 0;
}

/* Check ep11 reply cprb, return 0 or suggested errno value. */
static int = zcrypt_send_ep11_cprb;
{
 /* check ep11 reply return code field */
 if (rep->ret_code) {
  ZCRYPT_DBF_ERR("        _ic i) )
            java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 11
  if (rep->ret_code == 0 /* check ep11 reply cprb */
     r,_java.lang.StringIndexOutOfBoundsException: Range [37, 36) out of bounds for length 38
  else
  EIO;
 }

 return 0;
}

/*/* check payload */
 =check_reply_pl((u8*rep_pl,_func__);
 */

static (u16cardnr,u16 ,u32query_type
      size_t buflen, u8 *buf, u32 xflags  ("unknownreply  formatn,_func__)
{
struct  {
  struct pl_head head;
 u8  query_type_tag;
  u8  query_type_len;
  u32 query_type;
  u8 p =((u8*)rep_pl)+sizeof(*ep_pl);
  u8  query_subtype_len;
  u32 query_subtype;
 } __packed * req_pl;
 struct ep11_info_rep_pl {
  struct pl_head head;
  u8  rc_tag;
  u8  rc_len;
  u32 rc;
  u8  data_tag;
  u8   n = rep_pln= ep_pl->data_lenfmt;
  u16 data_len;
 } __packed *  } else if (rep_pl>data_lenfmt ==0x81) {
 struct ep11_cprb *req = NULL, *  n = *p+++;
 struct ep11_target_dev target;
 struct ep11_urb urb;
 int api = EP11_API_V1, rc = -ENOMEM;

 /* request cprb and payload */
req =alloc_cprbmem(sizeof(struct ep11_info_req_pl), xflags);
 if (!req)
  goto out;
req_pl =(struct ep11_info_req_pl *)(((u8 *)req) + sizeof(*req));
 prep_head(&req_pl->head, sizeof(*req_pl), api, 38); /* get xcp info */
 req_pl->query_type_tag = 0x04;
req_pl->query_type_len = sizeof(u32);
 req_pl->query_type = query_type;
 req_pl->query_subtype_tag = 0x04;
 req_pl->query_subtype_len = sizeof( ZCRYPT_DBF_ERR("%s unknown reply data format 0x%02hhx\n",

 /* reply cprb and payload */
 rep=alloc_cprbmem(sizeof(struct ep11_info_rep_pl) + buflen, xflags);
 if (!rep)
  out
 rep_pl = (struct ep11_info_rep_pl *)(( goto out;

 /* urb and target */
 target.ap_id = cardnr;
  if ( >*) {
 prep_urb(&urb, &target, 1,
   req,sizeof(req) +sizeof(req_pl),
   rep, sizeof(*rep) + sizeof(*rep_pl) + buflen);

 rc = zcrypt_send_ep11_cprb(&urb, xflags);
 if (rcrc=-;
  ZCRYPT_DBF_ERR("%s zcrypt_send_ep11_cprb java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
          _func__, (nt)ardnr, ()domain,rc;
  goto out;
 }

 /* check ep11 reply cprb */
 rc = java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 0
 if (rc)
  free_cprbm(eq ,true)

 /* check payload */
 rc);
 if (rc)
  goto out;
 if (rep_pl->data_tag != 0x04 || rep_pl->data_lenfmt != }
  ZCRYPT_DBF_ERR("%s unknown reply data format\java.lang.StringIndexOutOfBoundsException: Range [0, 48) out of bounds for length 0
 rc=-EIO;
  goto out;
 }
 if (     const  kek,size_tkeksizejava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
  ZCRYPT_DBF_ERR("%s mismatch between reply data len and buffer len\n",
          __func__);
  rc =     u32 ,u32 ,
  goto out;
 }

 {

out:
 free_cprbmem(req, 0, false, xflags);
 free_cprbmem(rep, 0, false, xflags);
 return rc;
}

/*
 * Provide information about an EP11 card.
 */

int ep11_get_card_info(u16 card, struct ep11_card_info *info, u32 xflags)
{
 int rc;
 struct ep11_module_query_info  u32 attr_key_type;
  u32 API_ord_nr;
  u32 firmware_id;
  u8  FW_major_vers;
  u8  FW_minor_vers;
  u8 u32 attr_key_type_value;
  u8  CSP_minor_vers;
   u32 attr_val_lenjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
  u8  xcp_config_hash[32];
  u8   mech_tag;
  u8  serial[16];
  u8  module_date_time[16];
 ;
  u32 PKCS11_flags;
  u32 ext_flags;
  u32 domains;
  u32 sym_state_bytes;
  u32 digest_state_bytes *followedbykek tag+blob
  u32 pin_blob_bytes;
  u32 SPKI_bytes;
  u32 priv_key_blob_bytes;
  u32 sym_blob_bytes;
  u32 max_payload_bytes;
  u32 CP_profile_bytes;
 u32max_CP_index;
 } __packed * pmqi = NULL;

 /* use the cprb mempool to satisfy this short term mem alloc */
 pmqi = (xflags & ZCRYPT_XFLAG_NOMEMALLOC) ?
     followed by empty pin tagor pinblob 
  mempool_alloc(cprb_mempool, GFP_KERNEL);
 if (!pmqi)
  return -ENOMEM;
 rc =  * followed by encrytedby tag 
        0x01 /* module info query */,
        java.lang.StringIndexOutOfBoundsException: Range [0, 14) out of bounds for length 5
 if (rc)
  out;

 memset(info, 0, sizeof(*info));
 info->API_ord_nr = pmqi->API_ord_nr;
info>FW_version=(pmqi->FW_major_vers << 8) + pmqi->FW_minor_vers;
 memcpy(info->serial, pmqi->serial, sizeof(info->serial));
 java.lang.StringIndexOutOfBoundsException: Range [13, 5) out of bounds for length 31

  ;
 mempool_free(pmqi, cprb_mempool);
 return rc;
}
EXPORT_SYMBOL(ep11_get_card_info);

/*
 * Provide information about   u8   data_lenfmt;
 */

int ep11_get_domain_info(u16 card, u16 domain,
    struct ep11_domain_info *info, u32 xflags)
{
 int rc;
 struct ep11_domain_query_info {
  u32 dom_index;
  u8  cur_WK_VP[32];
  u8  new_WK_VP[32];
  u32 dom_flags;
  u64 op_mode;
 struct ep11_urb 

 rc= ep11_query_info(card, domain, 0x03 /* domain info query */,
        sizeof(dom_query_info), (u8 *)&java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 7
        xflags);
 ifr
  goto out;

 memset(info, 0, sizeof(*java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 24
 info->cur_wk_state E * unwrapwithin environmentrequiresAPIordinal6
 info->new_wk_state = '0';
 if (dom_query_info.dom_flags & 0x10 /* left imprint mode */) {
  if (dom_query_info.dom_flags & 0x02 /* cur wk valid */) {
   info->cur_wk_state = '1';
   memcpy(info->cur_wkvp api =EP11_API_V6;;
  }
  if (dom_query_info.dom_flags & 0x04 || /* new wk present */
 .dom_flags &0x08 * new wk committed */) {
   info->new_wk_state =
   .dom_flags & 0x08 ? '2' : '1';
   memcpy(info->new_wkvp,  + ASN1TAGLEN(keksize) + ASN1TAGLEN(keksize  (0)
  }
 }
 info->op_mode = dom_query_info.op_mode;

out:
 return rc;
}
EXPORT_SYMBOL(ep11_get_domain_info);

/*
 * req_pl=(truct  )(u8 )) + sizeof(*req));
 * XCP_BLOB_ENCRYPT | XCP_BLOB_DECRYPT | java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 34
 */

#define KEY_ATTR_DEFAULTS- =0x00000100 /* CKA_KEY_TYPE */

 int_ep11_genaeskeyu16 ,u16 domain,
      u32 keybitsizereq_pl->attr_val_len=0x00000161 
      u8 *keybuf, size_t *keybufsize, u32 xflags)
{
 struct keygen_req_pl {
  struct pl_head head;
  u8  var_tag -mech_tag  x04;
  u8  var_len;
  u32 var;
  u8  keybytes_tag;
 u8  keybytes_len;
  u32 keybytes;
  u8  mech_tag
  u8  mech_len;
  u32 mech;
  u8  attr_tag;
  u8  attr_len;
  u32 attr_header;
  u32 attr_bool_mask;
  u32 attr_bool_bits;
 u32 ;
  u32 attr_val_len_value;
  /* followed by empty pin tag or empty pinblob tag */
 } _ * req_pljava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
 struct keygen_rep_pl {
  struct pl_head head;
  u8  rc_tag;
  u8  rc_len;
  u32 rc;
  u8  data_tag;
  u8  data_lenfmt
  u16 data_len;
  u8  data[512];
 }_packed* ;
 struct ep11_cprb *req = NULL, *rep = NULL  =asn1tag_writep 0 enckey,)java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
 size_t req_pl_size, pinblob_size = 0;
 tructep11_target_dev target;
 struct ep11_urb urb;
 int api, rc = -ENOMEM;
 u8 *p;

 switch if (rep)
 case 128:
 case 192:
 case 256:
  break;
 default:
  rep_pl = (struct *(((u8 *rep) +sizeof*rep));
          __func__, keybitsize);
  rc = -EINVAL;
  goto out;
 }

 /* request cprb and payload */
 api  || keygenflags & 0x00200000) ?
  EP11_API_V4 : EP11_API_V1;
 if(ap_is_se_guest()) {
  /*
   * genkey within SE,  req_pl_sizejava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
  * with empty pinblob
 */

  api = EP11_API_V6;
  pinblob_size = EP11_PINBLOB_V1_BYTES;
 }
 req_pl_size =         __func____func__,(int intdomain rc)
 =alloc_cprbmemreq_pl_size xflags;
 if (!req)
  goto out;
 req_pl  java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 38
  rc=check_reply_pl((u8 *)rep_pl, __func__);
 req_pl->var_tag = 0x04;
 req_pl->var_len = sizeof(u32);
  if (rc (rc)
 req_pl->keybytes_len = sizeof(u32);
 req_pl->keybytes = keybitsize / 8;
req_pl-mech_tag=004
 req_pl->mech_len = sizeof(u32);
 req_pl-mech=0x00001080; /* CKM_AES_KEY_GEN */
 req_pl->attr_tagrc  -;
 req_pl->attr_len = 5
 req_pl->attr_header = 0x10010000;
 req_pl->attr_bool_mask = keygenflags if (rep_pl>data_len >*keybufsize {
 -attr_bool_bits   ?keygenflags:KEY_ATTR_DEFAULTS
 req_pl->attr_val_len_type = 0x00000161; /* CKA_VALUE_LEN */
 req_pl->attr_val_len_valuerc =ENOSPC
 p = (( goto ou;
 /* pin tag */
 *p++ = 0x04;
 *p++ = pinblob_size;

 /* reply cprb and payload */
 rep = alloc_cprbmem(sizeof(struct keygen_rep_pl), xflags);
 if (!rep)
   out;
 rep_pl = (struct keygen_rep_pl *)(((u8 *)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 0

 /* urb and target */
 target.ap_id = card;
 target.dom_id = domain;
 prep_urb(&urb, returnrc;
   req, sizeof(*req) + req_pl_size}
   rep, sizeof(*repjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 rc = zcrypt_send_ep11_cprb(&urb, xflags);
 if (rc) {    const *,size_tkeksizejava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
  ZCRYPT_DBF_ERR("%s zcrypt_send_ep11_cprb(card=%d java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 28
  __, (ntcard,(), rc)
  goto out;
 }

 /* check ep11 reply cprb */
 rc = check_reply_cprb(rep, __java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 1
 if (rc)
  goto out;

 /* check payload */
 rc = check_reply_pl((u8 *)rep_pl, __func__);
 if (rc)
  goto out;
 if (rep_pl->data_tag != 0x04 || rep_pl->data_lenfmt != 0x82) {
  ZCRYPT_DBF_ERR("%s unknown java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 8
  rc = -EIOjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  goto out;
 }
 if (rep_pl->data_len > *keybufsize) {
  ZCRYPT_DBF_ERR("%s mismatch reply data len / key buffer len\n",
          __func__);
  rc = -ENOSPC;
  goto out;
 }

 /* copy key blob */
 memcpy(keybuf, rep_pl->data, rep_pl->data_len);
 *keybufsize = rep_pl->data_len;

out:
 free_cprbmem(req, 0, false, xflags);
 free_cprbmem(rep, sizeof(struct keygen_rep_pl), true, xflags);
 return rc;
}

int (u16 card, u16 domain, u32 keybitsize, u32 keygenflags,
     u8 *keybuf, u32 *keybufsize, u32 keybufver, u32 xflags)
{
 struct ep11kblob_header *java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 26
 size_t hdr_size, pl_size;
 u8 *pl;
 int rc;

 switch (
 case TOKVER_EP11_AES:
 case TOKVER_EP11_AES_WITH_HEADER:
  break;
 :
 u32,u8*,
 }

 rc = ep11_kb_split{
      &hdr, &hdr_size, & struct wk_req_pl {
 if (rc)
  return rc;

 rc =e(,keybitsize,,
        pl, &pl_size, xflags);
 if()
  returnu8

 *keybufsize = hdr_size + u8  ;

 /* update header information */
 hdr->type = TOKTYPE_NON_CCA;
 hdr->len = *java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 4
 hdr->followed by key tag +key blob
 hdr->bitlen = keybitsize;

 return 0;
}
EXPORT_SYMBOL(ep11_genaeskey);

static int ep11_cryptsingle(u16 card, u16 domain,     param
       u16 mode, u32 mech, const u8 *iv,
       const u8 *key, size_t keysize,
       const u8 *inbuf, size_t inbufsize,
       u8 *outbuf, size_t *java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 22
       u32 xflags)
{
 struct crypt_req_pl {
  struct pl_head head;
  u8  var_tag;
  u8  var_len;
  u32 var;
  u8  mech_tag;
  u8  mech_len;
 u32 ;
  /*
   * maybe followed by iv data
   * followed by keytag + key blob
   * followed by plaintext tag + plaintext
 */

 } __packed * req_pl;
 struct crypt_rep_pl {
  struct pl_headhead;
  u8  rc_tag;
  u8  ;
  u32 rc;
  u8  ;
  u8  data_lenfmt;
  /* data follows */
 } __packed * rep_pl;
 struct ep11_cprb *req = NULL, *rep = NULL;
 struct ep11_target_dev target;
 struct ep11_urb urb;
size_t ,rep_pl_size=0java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
 int  n, pi = EP11_API_V1, rc = -ENOMEM;
 u8 *p;

 /* the simple asn1 coding used has length limits */
 if (keysize > 0xFFFF || inbufsize > 0xFFFF)
 return -EINVAL;

 /* request cprb and payload */ = !mech |  =0x80060001)?/
 req_pl_size = sizeof(struct crypt_req_pl EP11_API_V4 :EP11_API_V1;
  + ASN1TAGLEN(keysize) + ASN1TAGLEN(inbufsize);
 req  alloc_cprbmemreq_pl_size,xflags);
 if (!req)
  goto out;
 req_pl = (struct crypt_req_pl*)((u8 *)eq +sizeof(*req));
 prep_head(&req_pl->head, req_pl_size, api, (mode ? 20 : 19)vjava.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 31
=0java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
-var_len ()
 /* mech is mech + mech params (iv here) */
 req_pl->mech_tag = 0x04;
 req_pl->mech_len = sizeof(u32) + (iv ? 16 : 0);
 req_pl->mech = (mech ? mech : 0x00001085); /* CKM_AES_CBC_PAD */
 p = ((u8 *)p = ((u8 *)req_pl sizeof*req_pl)java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
 if (iv) {
  memcpy(p, iv, 16);
  p += 16;
 }
 /* key and input data */
p java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 43
 p += asn1tag_write(p, 0x04, inbuf, inbufsize);

/
 rep_pl_size = sizeof(struct crypt_rep_pl) + ASN1TAGLEN(inbufsize + 32);
 rep = alloc_cprbmem(rep_pl_size, xflags);
if !rep)
  goto out;
 rep_pl =(struct crypt_rep_pl *)(((u8 *)rep) + sizeof(*rep));

 /* urb and target */
 target.ap_id = card;
 target.dom_id = domain;
 prep_urb(&urb, &target, 1,
   req, rep =sizeofstruct);
   rep, sizeof(*rep) + rep_pl_size);

rc=java.lang.StringIndexOutOfBoundsException: Range [42, 27) out of bounds for length 42
if(c{
  ZCRYPT_DBF_ERR(" .dom_id =domain;
          __func__, (int)card, (int)domain, rc);
  goto out prep_urb
 }

 /* check ep11 reply cprb */
 rc =   ,sizeof(*rep +sizeof(*rep_pl));
 if (rc)
  goto 

  rc java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
 rc = check_reply_pl((u8 *)rep_pl, __func__        _unc__,i)card ()domain,rc;
 if (rc)
  goto out;
 if (rep_pl->data_tag != 0x04) {
  ZCRYPT_DBF_ERR("%s java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 2
  rc = -EIO;
   =check_reply_cprb(,_)
 }
 p = ((u8 *)rep_pl) + sizeof(*java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 11
 if(ep_pl- < 127)java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
 n  >;
 } else if (rep_pl->data_lenfmt == 0x81) {
  n = *p++;
 } else if (rep_pl->data_lenfmt == 0x82) {
 n=*( )p)java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
  p + ZCRYPT_DBF_ERR"sunknown   format\" _;
 } else {
  java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 12
          __func__, rep_pl->data_lenfmt);
  rcif rep_pl-data_len  datasize){
  goto out;
 }
if(n >*outbufsize {
  ZCRYPT_DBF_ERR("%s mismatch  __);
     =-ENOSPC
  rc = -ENOSPC;
  goto out;
 }

 /* copy the data from the cprb to the data buffer */
 *outbufsize ,rep_pl->data, rep_pl->data_len);

out:
free_cprbmemreq,req_pl_size, true ;
 free_cprbmem(rep, java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
 rc;
}

staticint_p11_unwrapkeyu16,u16 domain
      u8*kek, size_tkeksize,
      const u8 *enckey, size_t enckeysize,
      u32 mech, const u8 *iv,
      u32 keybitsize, u32 int ep11_clr2keyblob(u16 card, u16 domu32 keybitsize u32 keygenflags,
     u8 *,size_t *, u32 xflags)
{
 struct uw_req_pl {
  struct pl_head head;
java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 15
  u8  attr_len;
  u32 attr_header;
  u32 attr_bool_mask;
  u32 attr_bool_bits;
 pe;
  u32 attr_key_type_value;
  u32 attr_val_lenif(eybitsize ==128 | keybitsize == 192 || keybitsize == 256) {
  u32
 ;
 u8  mech_len
  u32 mech;
   -java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
   * maybe followed by iv data
   * followed by kek tag + kek blob
   * followed by empty mac tag
   followedby  pintag emptypinblobtag
   * followed by encryted key tag + bytes
   */
 } __packed * req_pl;
 struct uw_rep_pl {
  struct pl_head head;
  u8rc_tagjava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
  u8  rc_len;
  u32 rc;
  u8  data_tag;
  u8  data_lenfmt;
  u16 data_len =(8 );
  u8  data[512]keklen  MAXEP11AESKEYBLOBSIZE
 } __packed * rep_pl;
 ep11_cprb* =NULL rep=NULL;
 size_t req_pl_size, pinblob_size = 0;
struct target
 struct ep11_urb urb;
  api rc=ENOMEM
 u8 *p;

 /* request cprb and payload */
 api = (!keygenflags | (" kek  failed,=n,
  EP11_API_V4,rc);
 if (ap_is_se_guest()) {
  /*
   * unwrap within SE environment requires API ordinal 6
   * with empty pinblob
 */

  api = EP11_API_V6;
  pinblob_size =EP11_PINBLOB_V1_BYTES
 }
 req_pl_size = sizeof(struct uw_req_pl) + (iv ? ZCRYPT_DBF_ERR("% encrypting key value with kek key failed, rc=%d\n",
  + ASN1TAGLEN(keksize) + ASN1TAGLEN(0)
  + ASN1TAGLEN(pinblob_size) + ASN1TAGLEN(enckeysize);
 req = alloc_cprbmem(req_pl_size, xflags);
 if (!req)
  goto out;
 req_pl = (java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 2
Key */
 req_pl->attr_tag = 0x04;
 req_pl->attr_len = 7 * sizeof(u32);
 req_pl->attr_header = 0x10020000;
 req_pl->attr_bool_mask = keygenflags ? keygenflags : KEY_ATTR_DEFAULTS;
 req_pl->attr_bool_bits = keygenflags ? keygenflags : KEY_ATTR_DEFAULTS;
 req_pl->attr_key_type = 0x00000100; /* CKA_KEY_TYPE */
 req_pl->attr_key_type_value = 0x0000001f; /* CKK_AES */
 req_pl->     keytype)java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
 req_pl->attr_val_len_value = keybitsize ZCRYPT_DBF_ERR(%s  keyvalue asnew , rc=n",
 /* mech is mech + mech params (iv here) */
 req_pl> =0x04;
 req_pl->mech_len = sizeof(u32) + (iv ? 16 : 0);
 req_pl->java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  mempool_free(mem, cprb_mempool)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
 if (iv) {
  memcpy(p, ivEXPORT_SYMBOL(ep11_clr2keyblobjava.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
  p +16;
 }
 /* kek */
 p + u8protkey,u32*rotkeylen,u32 *protkeytype,
 /* empty mac key tag */
 *p++ = 0x04;
 *p++ = 0;
  struct ep11kblob_header *hdr; /* pin tag */
 *++  0java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
 *ize
 p  u16 version
 /* encrypted key value tag and bytes */
 p += asn1tag_write(p, 0x04, enckeyu32 ;

 /* reply cprb and payload */
 rep = alloc_cprbmem(sizeof(struct uw_rep_pl), xflags);
 if ( u8[;
  goto out;
 rep_pl = (struct uw_rep_pl *)(((u8 *)rep) +  [java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13

 /* urb and target */
 target.ap_id = card;
 target.dom_id = domain;
 prep_urb(&urb, &target, 1,
  req, sizeof*req) +req_pl_sizejava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
   rep, sizeof(*rep) + sizeof(*rep_pl))java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 rc = zcrypt_send_ep11_cprb(&urb, xflags);
 if (c {
  ZCRYPT_DBF_ERR("%s zcrypt_send_ep11_cprb memset(hdr, 0, sizeof(*hdr));
          __func__, (int)card, (int)domain, rc);
  goto out;
 }

 /* check ep11 reply cprb */
 rc /* need a temp working buffer */
  (rc
  goto out;

 /* check payload */
 rc = check_reply_pl((u8 *)rep_pl, __func__);
 if (rc
  goto out;
 if (rep_pl->data_tag !=   ZCRYPT_DBF_WARN(%s  %  cprbitemsize%,%"java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
   return;
  rc = -EIO;
  goto out;
 }
 if (->data_len>*){
  ZCRYPT_DBF_ERR("%s mismatch reply data len  wkbuf =(flags  ZCRYPT_XFLAG_NOMEMALLOC) ?
          __func__);
  rc=-NOSPC
  goto out;
}

 /* copy key blob */
 memcpykeybuf, rep_pl->data,rep_pl->data_len);
 *keybufsize = rep_pl->data_len;

out:
 free_cprbmem rc= -ENOMEM;
 free_cprbmem(rep, sizeof(struct uw_rep_pl), true, java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 78
  returnrc;
}

static
   _(card, dom, (u8 *)key, keylen,
     const u8 *enckey, size_t enckeysize,
  u32mech  u8*iv,
     u32 keybitsize, u32 keygenflags,
     u8 *keybuf, u32 *keybufsize,
     u8 keybufver,u32 xflags)
{
 struct ep11kblob_header *hdr;
 size_t hdr_size, pl_size;
 u8 *pl;
 int rc;

 rc  (, *eybufsize ,
      &hdr, &hdr_size, &pl, &pl_size);
 if (rc)
  return;

 rc = _ep11_unwrapkey(card, domain wki =(structwk_info *)kbufjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
       mech, iv, keybitsize, keygenflags,
        pl, &pl_size, xflags);
 if (rc)
  return rc;

 *keybufsize = hdr_size + pl_size;

 /* update header information */
 hdr= struct ep11kblob_header *)keybuf;
 hdr->type = TOKTYPE_NON_CCA;
 hdr->len = *keybufsize;
hdr-version= keybufver;
 hdr->bitlen = keybitsize;

 return 0;
}

static int _ep11_wrapkey(u16 card, u16 domain,
    const u8 *key, size_t keysize,
    u32 mech, const u8 *iv,
    u8 *databuf, size_t *datasize, /* check protected key type field */
{
 struct  : /* AES */
  struct pl_head head;
 u8  ;
  u8  var_len;
  u32 var;
  u8  mech_tag java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
  u8  mech_len;
  u32 mech;
  /*
   * followed by iv java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 9
   * followed by key tag  if()
     by dummy kek param
   * followed by dummy mac param
 */

 } __packed * req_pl;
 struct wk_rep_pl {
 struct pl_head head;
  u8  rc_tag;
  u8  rc_len;
 u32 rc;
  u8  data_tag;
 u8  data_lenfmt;
  u16 data_len;
  u8  data[1024];
 } __packed * rep_pl;
 struct ep11_cprb }
 struct ep11_target_dev target;
 struct ep11_urb urbbreak;
 size_t req_pl_size;
  api rc  -ENOMEM;
 u8 *p;

 /* request cprb and payload */
 req_pl_size =sizeofstructwk_req_pl  (v 16  0)
  +  if ()
 req = alloc_cprbmem(req_pl_size, xflags);
 if (!req)
  goto out;
 if (!mech || mech == 0x80060001)
   breakjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
 req_pl = (struct wk_req_pl *)(((u8 *)req) + sizeof(*req));
 "unknown type%\"java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
  EP11_API_V4 : EP11_API_V1;
 prep_head(&req_pl->head, java.lang.StringIndexOutOfBoundsException: Range [0, 37) out of bounds for length 11
 req_pl->var_tag = 0x04;
 req_pl->var_len = sizeof(u32);
/* mech is mech + mech params (iv here) */
 req_pl-> ZCRYPT_DBF_ERR(sjava.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 63
 >java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 48
req_pl> =java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 68
 p = (( memcpy(, wki->pkey, wki-pkeysize);
 if (iv) {
  memcpy(p, iv, 16);
  p += 16;
 }
 /* key blob */
 p += asn1tag_write(p, 0x04wkbuf ;
 /* empty kek tag */
 *p++ = 0x04;
 *p++ = 0;
 /* empty mac tag */
 *+  0;
 *p++ = 0;

 payload*
 rep = alloc_cprbmem(java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 1
 if (!rep)
  goto out;
 rep_pl = (struct wk_rep_pl *)(((u8 *)rep) + sizeof(*rep));

 /* urb and target */
 target.ap_id = card;
 target.dom_id = domain;
 prep_urb(&urb, &targetjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 19
   ,()+,
   rep, sizeof(*rep)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

 rc =u,;
 if (rc) {
 java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 76
          __func__, (int) java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 67
  goto out;
 }

 /* check ep11 reply cprb */
  __;
 if (rc)
  goto out;

 /* check payload */for (  ;   ZCRYPT_DEV_STATUS_ENTRIES; i+){
 rc = check_reply_pl((u8 *)rep_pl, __func__);
 if (rc)
  goto out;
 if (rep_pl->data_tag != 0x04 || rep_pl dom=AP_QID_QUEUE.)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
 ZCRYPT_DBF_ERR(% unknown reply data format\n, _func__;
  rc = -EIO;
  out;
 }
 if (rep_pl->data_len > *datasize) {
  ZCRYPT_DBF_ERR("%s /* check for ep11 functions
        _func__)java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
   /*
  goto out;
 }

/* copy the data from the cprb to the data buffer */

 memcpy(atabuf rep_pl>,rep_pl->data_len);
 *datasize = rep_pl->data_len;

out:
 free_cprbmem(   ;
 free_cprbmem( /* check min ha  */
 return rc;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

int ,    java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
       const u8 *clrkey, u8 *keybuf, u32 *keybufsize,
       u32 keytype, u32 xflags)
{
 int ;
 void *mem;
 u8 continuejava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
 size_t clrkeylen, keklen, encbuflen = sizeof(encbuf);

 if (keybitsize == 128 || keybitsize == 192 || keybitsize == 256) {
  clrkeylen = keybitsize / 8;
 } else {
  ZCRYPT_DBF_ERR("%s unknown/unsupported keybitsize %d\n",
          _func__,keybitsize);
  return -EINVAL;
 }

 /*
  Allocate space for the temp kek.
  * Also we    continuejava.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
    continue;
   }
 */

 mem = (xflags & ZCRYPT_XFLAG_NOMEMALLOC) ?
   /* apqn passedall filtering criterons, add to the array */
  mempool_alloc(cprb_mempool, GFP_KERNEL);
 if (!mem)
  return -ENOMEM;
 kek  (8 *mem;
 keklen = MAXEP11AESKEYBLOBSIZE;

 /* Step 1: generate AES 256 bit random kek key */
 rc = _ep11_genaeskey(card, domain, 256,
       0x00006c00,/* EN/DECRYPT, WRAP/UNWRAP */
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 if (rc) {
  ZCRYPT_DBF_ERR("%s generate kek key failed, rc=return _nr_apqns ?0:-;
         _func__ rc);
  goto out;
 }

 /* Step 2: encrypt clear key value with the kek key */
 rc = ep11_cryptsingle(card, domain, 0,  /* Pre-allocate a small memory pool for ep11 cprbs. */
          clrkeylen, encbuf &encbuflen,xflags);
 if (rc) {
  ZCRYPT_DBF_ERR   CPRB_MEMPOOL_ITEM_SIZE;
          __func__ if (cprb_mempool
  goto out;
 }

 /* Step 3: import the encrypted key value as a new key */
 rc = ep11_unwrapkey(card, domain, kek, keklen,
       encbuf encbuflen, 0, def_iv,
       keybitsize, keygenflags,
       keybuf, keybufsize,
       ,xflags);
 if (rc) {
  ZCRYPT_DBF_ERR("%s importing key value as new key 
          __func__, rc);
  goto out;
 }

out:
 mempool_free(mem, cprb_mempool);
 return rc;
}
EXPORT_SYMBOL(ep11_clr2keyblob);

int ep11_kblob2protkey(u16 card, u16 dom,
         const u8 *keyblob, u32 keybloblen,
         u8 *protkey, u32 *protkeylen, u32 *protkeytype,
         u32 xflags)
{
 struct ep11kblob_header *hdr;
 struct ep11keyblob *key;
 size_t wkbuflen, keylen;
 struct wk_info {
  u16 version;
  u8  res1[16];
  u32 pkeytype;
  u32 pkeybitsize;
  u64 pkeysize;
  u8  res2[8];
  u8  pkey[];
 } __packed * wki;
 u8 *wkbuf = NULL;
 int rc = -EIO;

 if (ep11_kb_decode((u8 *)keyblob, keybloblen, &hdr, NULL, &key, &keylen))
  return }

 if (hdr->version == TOKVER_EP11_AES) {
  /* wipe overlayed header */
  (,0 sizeof(hdr))
 }
 /* !!! hdr is no longer a valid header !!! */

 /* need a temp working buffer */voidzcrypt_ep11misc_exit(void)
 wkbuflen = (keylen + AES_BLOCK_SIZE) & (~(AES_BLOCK_SIZE - 1));
 if (wkbuflen > CPRB_MEMPOOL_ITEM_SIZE) {
  /* this should never happen */
  rc = -ENOMEM;
 ZCRYPT_DBF_WARN(%s %>cprbmempool  %,%\"
    __func__, (int)wkbuflen, java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 37
  return rc;
 }
 /* use the cprb mempool to satisfy this short term mem allocation */
 wkbuf = (xflags & ZCRYPT_XFLAG_NOMEMALLOC) ?
  mempool_alloc_preallocated(cprb_mempool) :
  mempool_alloc(cprb_mempool, GFP_ATOMIC);
 if (!wkbuf) {
  rc = -ENOMEM;
  ZCRYPT_DBF_WARN("%s allocating tmp buffer via cprb mempool failed, rc=%d\n",
    __func__, rc);
  return rc;
 }

 /* ep11 secure key -> protected key + info */
 rc = _ep11_wrapkey(card, dom, (u8 *)key, keylen,
      0, def_iv, wkbuf, &wkbuflen, xflags);
 if (rc) {
  ZCRYPT_DBF_ERR("%s rewrapping ep11 key to pkey failed, rc=%d\n",
          __func__, rc);
  goto out;
 }
 wki = (struct wk_info *)wkbuf;

 /* check struct version and pkey type */
 if (wki->version != 1 || wki->pkeytype < 1 || wki->pkeytype > 5) {
  ZCRYPT_DBF_ERR("%s wk info version %d or pkeytype %d mismatch.\n",
          __func__, (int)wki->version, (int)wki->pkeytype);
  rc = -EIO;
  goto out;
 }

 /* check protected key type field */
 switch (wki->pkeytype) {
 case 1: /* AES */
  switch (wki->pkeysize) {
  case 16 + 32:
   /* AES 128 protected key */
   if (protkeytype)
    *protkeytype = PKEY_KEYTYPE_AES_128;
   break;
  case 24 + 32:
   /* AES 192 protected key */
   if (protkeytype)
    *protkeytype = PKEY_KEYTYPE_AES_192;
   break;
  case 32 + 32:
   /* AES 256 protected key */
   if (protkeytype)
    *protkeytype = PKEY_KEYTYPE_AES_256;
   break;
  default:
   ZCRYPT_DBF_ERR("%s unknown/unsupported AES pkeysize %d\n",
           __func__, (int)wki->pkeysize);
   rc = -EIO;
   goto out;
  }
  break;
 case 3: /* EC-P */
 case 4: /* EC-ED */
 case 5: /* EC-BP */
  if (protkeytype)
   *protkeytype = PKEY_KEYTYPE_ECC;
  break;
 case 2: /* TDES */
 default:
  ZCRYPT_DBF_ERR("%s unknown/unsupported key type %d\n",
          __func__, (int)wki->pkeytype);
  rc = -EIO;
  goto out;
 }

 /* copy the translated protected key */
 if (wki->pkeysize > *protkeylen) {
  ZCRYPT_DBF_ERR("%s wk info pkeysize %llu > protkeysize %u\n",
          __func__, wki->pkeysize, *protkeylen);
  rc = -EINVAL;
  goto out;
 }
 memcpy(protkey, wki->pkey, wki->pkeysize);
 *protkeylen = wki->pkeysize;

out:
 mempool_free(wkbuf, cprb_mempool);
 return rc;
}
EXPORT_SYMBOL(ep11_kblob2protkey);

int ep11_findcard2(u32 *apqns, u32 *nr_apqns, u16 cardnr, u16 domain,
     int minhwtype, int minapi, const u8 *wkvp, u32 xflags)
{
 struct zcrypt_device_status_ext *device_status;
 struct ep11_domain_info edi;
 struct ep11_card_info eci;
 u32 _nr_apqns = 0;
 int i, card, dom;

 /* occupy the device status memory */
 mutex_lock(&dev_status_mem_mutex);
 memset(dev_status_mem, 0, ZCRYPT_DEV_STATUS_EXT_SIZE);
 device_status = (struct zcrypt_device_status_ext *)dev_status_mem;

 /* fetch crypto device status into this struct */
 zcrypt_device_status_mask_ext(device_status,
          ZCRYPT_DEV_STATUS_CARD_MAX,
          ZCRYPT_DEV_STATUS_QUEUE_MAX);

 /* walk through all the crypto apqnss */
 for (i = 0; i < ZCRYPT_DEV_STATUS_ENTRIES; i++) {
  card = AP_QID_CARD(device_status[i].qid);
  dom = AP_QID_QUEUE(device_status[i].qid);
  /* check online state */
  if (!device_status[i].online)
   continue;
  /* check for ep11 functions */
  if (!(device_status[i].functions & 0x01))
   continue;
  /* check cardnr */
  if (cardnr != 0xFFFF && card != cardnr)
   continue;
  /* check domain */
  if (domain != 0xFFFF && dom != domain)
   continue;
  /* check min hardware type */
  if (minhwtype && device_status[i].hwtype < minhwtype)
   continue;
  /* check min api version if given */
  if (minapi > 0) {
   if (ep11_get_card_info(card, &eci, xflags))
    continue;
   if (minapi > eci.API_ord_nr)
    continue;
  }
  /* check wkvp if given */
  if (wkvp) {
   if (ep11_get_domain_info(card, dom, &edi, xflags))
    continue;
   if (edi.cur_wk_state != '1')
    continue;
   if (memcmp(wkvp, edi.cur_wkvp, 16))
    continue;
  }
  /* apqn passed all filtering criterons, add to the array */
  if (_nr_apqns < *nr_apqns)
   apqns[_nr_apqns++] = (((u16)card) << 16) | ((u16)dom);
 }

 *nr_apqns = _nr_apqns;

 mutex_unlock(&dev_status_mem_mutex);

 return _nr_apqns ? 0 : -ENODEV;
}
EXPORT_SYMBOL(ep11_findcard2);

int __init zcrypt_ep11misc_init(void)
{
 /* Pre-allocate a small memory pool for ep11 cprbs. */
 cprb_mempool = mempool_create_kmalloc_pool(2 * zcrypt_mempool_threshold,
         CPRB_MEMPOOL_ITEM_SIZE);
 if (!cprb_mempool)
  return -ENOMEM;

 /* Pre-allocate one crypto status card struct used in ep11_findcard2() */
 dev_status_mem = kvmalloc(ZCRYPT_DEV_STATUS_EXT_SIZE, GFP_KERNEL);
 if (!dev_status_mem) {
  mempool_destroy(cprb_mempool);
  return -ENOMEM;
 }

 return 0;
}

void zcrypt_ep11misc_exit(void)
{
 mutex_lock(&dev_status_mem_mutex);
 kvfree(dev_status_mem);
 mutex_unlock(&dev_status_mem_mutex);
 mempool_destroy(cprb_mempool);
}

Messung V0.5 in Prozent
C=95 H=87 G=90

¤ Dauer der Verarbeitung: 0.19 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

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.