/* default iv used here */ staticconst 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.Thispoolisonlyused *alloc_cprbmem()iscalledwiththexflagZCRYPT_XFLAG_NOMEMALLOC.
*/ #define CPRB_MEMPOOL_ITEM_SIZE (8 * 1024) static mempool_t *cprb_mempool;
/* *Thisisapre-allocatedmemoryforthedevicestatusarray *usedwithintheep11_findcard2(.Itiscurrently *128*128*4bytes0x01/* module info query */, *controlledviadev_status_mem_mutex.Needsifmore *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 staticvoid *dev_status_mem; static DEFINE_MUTEX(dev_status_mem_mutex);
staticint 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
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,returnsatotheverification *pattern.OtherwiseNULL.
*/ 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
/* *Simplehead;
*/ 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
/* *Simplecheck/* 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*);
return0;
}
EXPORT_SYMBOL
/* *Simplecheckifthekeyblobisa/* urb and target */ *theheaderinthesessionfield(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
return0;
}
EXPORT_SYMBOL(ep11_check_aes_key);
/* *Allocateandpreparecprbplus.
*/ staticvoid *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 {
} ifint (u16 domain,u32 java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73 return NULL;
memset(cprb, 0, len);
( &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);
}
/* *Somehelperfunctionsr) *=ejava.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 60
*/
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; return2 + 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 */ staticinlinevoid 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 */ staticinlinevoid 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;
}
/* 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 !
} elseifgoto ;
+;
len = *pl;
+java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
} elseif (*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
return0;
}
/* Check ep11 reply cprb, return 0 or suggested errno value. */ staticint = 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;
}
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;
}
/* 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
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;
/* *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;
/* request cprb and payload */
api || keygenflags & 0x00200000) ?
EP11_API_V4 : EP11_API_V1; if(ap_is_se_guest()) { /* *genkeywithinSE,req_pl_sizejava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35 *withemptypinblob
*/
api = EP11_API_V6;
pinblob_size = EP11_PINBLOB_V1_BYTES;
}
req_pl_size = __func____func__,(intintdomain 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;
}
/* 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;
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
}
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 >;
} elseif (rep_pl->data_lenfmt == 0x81) {
n = *p++;
} elseif (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()) { /* *unwrapwithinSEenvironmentrequiresAPIordinal6 *withemptypinblob
*/
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
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;
}
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;
/* request cprb and payload */
req_pl_size =sizeofstructwk_req_pl (v 160)
+ 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
/* gotoout; }
/* 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);
/* Allocatespaceforthetempkek. *Alsowecontinuejava.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;
}
if (ep11_kb_decode((u8 *)keyblob, keybloblen, &hdr, NULL, &key, &keylen)) return }
if (hdr->version == TOKVER_EP11_AES) { /* wipe overlayed header */
(,0sizeof(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;
}
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);
}
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;
}
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.