Lines Matching refs:template

259 kernel_validate_attr(CK_ATTRIBUTE_PTR template, CK_ULONG ulAttrNum,
268 switch (template[i].type) {
270 *class = *((CK_OBJECT_CLASS*)template[i].pValue);
284 switch (template[i].type) {
305 rv = kernel_lookup_attr(template[i].type);
354 kernel_add_extra_attr(CK_ATTRIBUTE_PTR template, kernel_object_t *object_p)
366 attrp->attr.type = template->type;
367 attrp->attr.ulValueLen = template->ulValueLen;
369 if ((template->pValue != NULL) &&
370 (template->ulValueLen > 0)) {
372 attrp->attr.pValue = malloc(template->ulValueLen);
378 (void) memcpy(attrp->attr.pValue, template->pValue,
379 template->ulValueLen);
446 * (if the specified attribute type is found), and copy it to a template.
447 * Note the type of the attribute to be copied is specified by the template,
448 * and the storage is pre-allocated for the atrribute value in the template
452 get_extra_attr_from_object(kernel_object_t *object_p, CK_ATTRIBUTE_PTR template)
456 CK_ATTRIBUTE_TYPE type = template->type;
472 template->ulValueLen = 0;
479 if (template->pValue == NULL) {
480 template->ulValueLen = extra_attr->attr.ulValueLen;
484 if (template->ulValueLen >= extra_attr->attr.ulValueLen) {
489 (void) memcpy(template->pValue, extra_attr->attr.pValue,
491 template->ulValueLen = extra_attr->attr.ulValueLen;
498 template->ulValueLen = (CK_ULONG)-1;
511 CK_ATTRIBUTE_PTR template)
533 return (kernel_add_extra_attr(template, object_p));
537 if ((template->pValue != NULL) &&
538 (template->ulValueLen > 0)) {
539 if (template->ulValueLen > extra_attr->attr.ulValueLen) {
546 extra_attr->attr.pValue = malloc(template->ulValueLen);
553 extra_attr->attr.ulValueLen = template->ulValueLen;
554 (void) memcpy(extra_attr->attr.pValue, template->pValue,
555 template->ulValueLen);
565 * Copy the big integer attribute value from template to a biginteger_t struct.
568 get_bigint_attr_from_template(biginteger_t *big, CK_ATTRIBUTE_PTR template)
571 if ((template->pValue != NULL) &&
572 (template->ulValueLen > 0)) {
574 big->big_value = malloc(template->ulValueLen);
579 (void) memcpy(big->big_value, template->pValue,
580 template->ulValueLen);
581 big->big_value_len = template->ulValueLen;
593 * object to a template.
596 get_bigint_attr_from_object(biginteger_t *big, CK_ATTRIBUTE_PTR template)
599 if (template->pValue == NULL) {
600 template->ulValueLen = big->big_value_len;
605 template->ulValueLen = 0;
609 if (template->ulValueLen >= big->big_value_len) {
614 (void) memcpy(template->pValue, big->big_value,
616 template->ulValueLen = big->big_value_len;
623 template->ulValueLen = (CK_ULONG)-1;
631 * specified attribute to the template.
635 CK_ATTRIBUTE_PTR template)
638 if (template->pValue == NULL) {
639 template->ulValueLen = sizeof (CK_BBOOL);
643 if (template->ulValueLen >= sizeof (CK_BBOOL)) {
649 *((CK_BBOOL *)template->pValue) = B_TRUE;
651 *((CK_BBOOL *)template->pValue) = B_FALSE;
654 template->ulValueLen = sizeof (CK_BBOOL);
661 template->ulValueLen = (CK_ULONG)-1;
671 CK_ATTRIBUTE_PTR template)
674 if (*(CK_BBOOL *)template->pValue)
685 * template.
688 get_ulong_attr_from_object(CK_ULONG value, CK_ATTRIBUTE_PTR template)
691 if (template->pValue == NULL) {
692 template->ulValueLen = sizeof (CK_ULONG);
696 if (template->ulValueLen >= sizeof (CK_ULONG)) {
701 *(CK_ULONG_PTR)template->pValue = value;
702 template->ulValueLen = sizeof (CK_ULONG);
709 template->ulValueLen = (CK_ULONG)-1;
716 * Copy the CK_ULONG data type attribute value from a template to the
720 get_ulong_attr_from_template(CK_ULONG *value, CK_ATTRIBUTE_PTR template)
723 if (template->pValue != NULL) {
724 *value = *(CK_ULONG_PTR)template->pValue;
788 string_attr_cleanup(CK_ATTRIBUTE_PTR template)
791 if (template->pValue) {
792 free(template->pValue);
793 template->pValue = NULL;
794 template->ulValueLen = 0;
925 * value to indicate if the supplied template specifies a valid attribute
929 kernel_parse_common_attrs(CK_ATTRIBUTE_PTR template, kernel_session_t *sp,
936 switch (template->type) {
942 if ((*(CK_BBOOL *)template->pValue) == TRUE) {
948 if ((*(CK_BBOOL *)template->pValue) == TRUE) {
963 if ((*(CK_BBOOL *)template->pValue) == FALSE) {
984 * - Parse the object's template, and when an error is detected such as
999 kernel_build_public_key_object(CK_ATTRIBUTE_PTR template,
1048 switch (template[i].type) {
1052 keytype = *((CK_KEY_TYPE*)template[i].pValue);
1066 rv = kernel_add_extra_attr(&template[i],
1084 if (*(CK_BBOOL *)template[i].pValue)
1089 if (*(CK_BBOOL *)template[i].pValue)
1096 if (*(CK_BBOOL *)template[i].pValue)
1103 if (*(CK_BBOOL *)template[i].pValue)
1110 if (*(CK_BBOOL *)template[i].pValue)
1115 if (*(CK_BBOOL *)template[i].pValue)
1127 * Copyin big integer attribute from template
1131 &template[i]);
1139 &template[i]);
1147 &template[i]);
1155 &template[i]);
1163 &template[i]);
1171 &template[i]);
1179 &template[i]);
1185 &template[i]);
1193 &template[i]);
1201 &template[i]);
1207 rv = kernel_parse_common_attrs(&template[i], sp,
1352 * - Parse the object's template, and when an error is detected such as
1367 kernel_build_private_key_object(CK_ATTRIBUTE_PTR template,
1433 switch (template[i].type) {
1437 keytype = *((CK_KEY_TYPE*)template[i].pValue);
1451 rv = kernel_add_extra_attr(&template[i],
1472 if (*(CK_BBOOL *)template[i].pValue)
1477 if (*(CK_BBOOL *)template[i].pValue)
1482 if (*(CK_BBOOL *)template[i].pValue) {
1489 if (*(CK_BBOOL *)template[i].pValue)
1496 if (*(CK_BBOOL *)template[i].pValue)
1503 if (*(CK_BBOOL *)template[i].pValue)
1510 if (*(CK_BBOOL *)template[i].pValue)
1515 if (*(CK_BBOOL *)template[i].pValue)
1529 * Copyin big integer attribute from template
1533 &template[i]);
1541 &template[i]);
1549 &template[i]);
1557 &template[i]);
1565 &template[i]);
1573 &template[i]);
1581 &template[i]);
1589 &template[i]);
1597 &template[i]);
1605 &template[i]);
1613 &template[i]);
1621 &template[i]);
1629 &template[i]);
1635 &template[i]);
1643 &template[i]);
1649 rv = kernel_parse_common_attrs(&template[i], sp,
1826 * - Parse the object's template, and when an error is detected such as
1841 kernel_build_secret_key_object(CK_ATTRIBUTE_PTR template,
1874 switch (template[i].type) {
1878 keytype = *((CK_KEY_TYPE*)template[i].pValue);
1889 rv = kernel_add_extra_attr(&template[i],
1909 if (*(CK_BBOOL *)template[i].pValue)
1914 if (*(CK_BBOOL *)template[i].pValue)
1919 if (*(CK_BBOOL *)template[i].pValue)
1926 if (*(CK_BBOOL *)template[i].pValue)
1933 if (*(CK_BBOOL *)template[i].pValue)
1940 if (*(CK_BBOOL *)template[i].pValue)
1947 if (*(CK_BBOOL *)template[i].pValue)
1952 if (*(CK_BBOOL *)template[i].pValue)
1957 if (*(CK_BBOOL *)template[i].pValue)
1965 if ((template[i].ulValueLen == 0) ||
1966 (template[i].pValue == NULL)) {
1972 * Copyin attribute from template
1975 sck->sk_value = malloc(template[i].ulValueLen);
1980 (void) memcpy(sck->sk_value, template[i].pValue,
1981 template[i].ulValueLen);
1982 sck->sk_value_len = template[i].ulValueLen;
1992 &template[i]);
1998 rv = kernel_parse_common_attrs(&template[i], sp,
2127 * Validate the attribute types in the object's template. Then,
2129 * the object specified in the template.
2137 kernel_build_object(CK_ATTRIBUTE_PTR template, CK_ULONG ulAttrNum,
2144 if (template == NULL) {
2148 /* Validate the attribute type in the template. */
2149 rv = kernel_validate_attr(template, ulAttrNum, &class);
2162 rv = kernel_build_public_key_object(template, ulAttrNum,
2167 rv = kernel_build_private_key_object(template, ulAttrNum,
2172 rv = kernel_build_secret_key_object(template, ulAttrNum,
2194 kernel_get_common_attrs(kernel_object_t *object_p, CK_ATTRIBUTE_PTR template)
2199 switch (template->type) {
2203 template));
2208 template->ulValueLen = sizeof (CK_BBOOL);
2209 if (template->pValue == NULL) {
2217 *((CK_BBOOL *)template->pValue) = B_FALSE;
2222 template->ulValueLen = sizeof (CK_BBOOL);
2223 if (template->pValue == NULL) {
2227 *((CK_BBOOL *)template->pValue) = B_TRUE;
2229 *((CK_BBOOL *)template->pValue) = B_FALSE;
2234 template->ulValueLen = sizeof (CK_BBOOL);
2235 if (template->pValue == NULL) {
2239 *((CK_BBOOL *)template->pValue) = B_TRUE;
2241 *((CK_BBOOL *)template->pValue) = B_FALSE;
2246 template));
2253 template->ulValueLen = (CK_ULONG)-1;
2266 CK_ATTRIBUTE_PTR template)
2269 switch (template->type) {
2273 template));
2282 template));
2287 LOCAL_BOOL_ON, template));
2291 DERIVE_BOOL_ON, template));
2295 template));
2310 CK_ATTRIBUTE_PTR template)
2316 switch (template->type) {
2324 template));
2329 ENCRYPT_BOOL_ON, template));
2333 VERIFY_BOOL_ON, template));
2337 VERIFY_RECOVER_BOOL_ON, template));
2341 WRAP_BOOL_ON, template));
2345 TRUSTED_BOOL_ON, template));
2354 OBJ_PUB_RSA_MOD(object_p), template));
2356 template->ulValueLen = (CK_ULONG)-1;
2363 OBJ_PUB_RSA_PUBEXPO(object_p), template));
2365 template->ulValueLen = (CK_ULONG)-1;
2372 OBJ_PUB_RSA_MOD_BITS(object_p), template));
2374 template->ulValueLen = (CK_ULONG)-1;
2382 OBJ_PUB_DSA_PRIME(object_p), template));
2385 OBJ_PUB_DH_PRIME(object_p), template));
2387 template->ulValueLen = (CK_ULONG)-1;
2395 OBJ_PUB_DSA_SUBPRIME(object_p), template));
2397 template->ulValueLen = (CK_ULONG)-1;
2405 OBJ_PUB_DSA_BASE(object_p), template));
2408 OBJ_PUB_DH_BASE(object_p), template));
2410 template->ulValueLen = (CK_ULONG)-1;
2418 OBJ_PUB_DSA_VALUE(object_p), template));
2421 OBJ_PUB_DH_VALUE(object_p), template));
2423 template->ulValueLen = (CK_ULONG)-1;
2431 OBJ_PUB_EC_POINT(object_p), template));
2433 template->ulValueLen = (CK_ULONG)-1;
2443 rv = kernel_get_common_key_attrs(object_p, template);
2445 rv = kernel_get_common_attrs(object_p, template);
2464 CK_ATTRIBUTE_PTR template)
2479 switch (template->type) {
2487 template->ulValueLen = (CK_ULONG)-1;
2492 switch (template->type) {
2500 template));
2505 SENSITIVE_BOOL_ON, template));
2509 SECONDARY_AUTH_BOOL_ON, template));
2513 DECRYPT_BOOL_ON, template));
2517 SIGN_BOOL_ON, template));
2521 SIGN_RECOVER_BOOL_ON, template));
2525 UNWRAP_BOOL_ON, template));
2529 EXTRACTABLE_BOOL_ON, template));
2533 ALWAYS_SENSITIVE_BOOL_ON, template));
2537 NEVER_EXTRACTABLE_BOOL_ON, template));
2542 OBJ_PRI_RSA_MOD(object_p), template));
2544 template->ulValueLen = (CK_ULONG)-1;
2552 OBJ_PRI_RSA_PUBEXPO(object_p), template));
2554 template->ulValueLen = (CK_ULONG)-1;
2562 OBJ_PRI_RSA_PRIEXPO(object_p), template));
2564 template->ulValueLen = (CK_ULONG)-1;
2572 OBJ_PRI_RSA_PRIME1(object_p), template));
2574 template->ulValueLen = (CK_ULONG)-1;
2582 OBJ_PRI_RSA_PRIME2(object_p), template));
2584 template->ulValueLen = (CK_ULONG)-1;
2592 OBJ_PRI_RSA_EXPO1(object_p), template));
2594 template->ulValueLen = (CK_ULONG)-1;
2602 OBJ_PRI_RSA_EXPO2(object_p), template));
2604 template->ulValueLen = (CK_ULONG)-1;
2612 OBJ_PRI_RSA_COEF(object_p), template));
2614 template->ulValueLen = (CK_ULONG)-1;
2622 OBJ_PRI_DH_VAL_BITS(object_p), template));
2624 template->ulValueLen = (CK_ULONG)-1;
2633 OBJ_PRI_DSA_PRIME(object_p), template));
2636 OBJ_PRI_DH_PRIME(object_p), template));
2638 template->ulValueLen = (CK_ULONG)-1;
2646 OBJ_PRI_DSA_SUBPRIME(object_p), template));
2648 template->ulValueLen = (CK_ULONG)-1;
2656 OBJ_PRI_DSA_BASE(object_p), template));
2659 OBJ_PRI_DH_BASE(object_p), template));
2661 template->ulValueLen = (CK_ULONG)-1;
2669 OBJ_PRI_DSA_VALUE(object_p), template));
2672 OBJ_PRI_DH_VALUE(object_p), template));
2675 OBJ_PRI_EC_VALUE(object_p), template));
2677 template->ulValueLen = (CK_ULONG)-1;
2688 rv = kernel_get_common_key_attrs(object_p, template);
2690 rv = kernel_get_common_attrs(object_p, template);
2709 CK_ATTRIBUTE_PTR template)
2715 switch (template->type) {
2720 SENSITIVE_BOOL_ON, template));
2724 ENCRYPT_BOOL_ON, template));
2728 DECRYPT_BOOL_ON, template));
2732 SIGN_BOOL_ON, template));
2736 VERIFY_BOOL_ON, template));
2740 WRAP_BOOL_ON, template));
2744 UNWRAP_BOOL_ON, template));
2748 EXTRACTABLE_BOOL_ON, template));
2752 ALWAYS_SENSITIVE_BOOL_ON, template));
2756 NEVER_EXTRACTABLE_BOOL_ON, template));
2766 template->ulValueLen = (CK_ULONG)-1;
2781 * Copy secret key object attributes to template.
2783 if (template->pValue == NULL) {
2784 template->ulValueLen =
2790 template->ulValueLen = 0;
2794 if (template->ulValueLen >=
2796 (void) memcpy(template->pValue,
2799 template->ulValueLen =
2803 template->ulValueLen = (CK_ULONG)-1;
2808 template->ulValueLen = (CK_ULONG)-1;
2816 template));
2825 rv = kernel_get_common_key_attrs(object_p, template);
2827 rv = kernel_get_common_attrs(object_p, template);
2846 kernel_get_attribute(kernel_object_t *object_p, CK_ATTRIBUTE_PTR template)
2855 rv = kernel_get_public_key_attribute(object_p, template);
2859 rv = kernel_get_private_key_attribute(object_p, template);
2863 rv = kernel_get_secret_key_attribute(object_p, template);
2872 template->ulValueLen = (CK_ULONG)-1;
2886 CK_ATTRIBUTE_PTR template, boolean_t copy, kernel_session_t *sp)
2892 switch (template->type) {
2900 CKA_LABEL, template));
2904 CKA_ID, template));
2908 CKA_START_DATE, template));
2912 CKA_END_DATE, template));
2916 DERIVE_BOOL_ON, template));
2930 if ((*(CK_BBOOL *)template->pValue) != B_TRUE) {
2944 PRIVATE_BOOL_ON, template);
2952 MODIFIABLE_BOOL_ON, template);
2973 CK_ATTRIBUTE_PTR template, boolean_t copy, kernel_session_t *sp)
2977 switch (template->type) {
2981 CKA_SUBJECT, template));
2985 ENCRYPT_BOOL_ON, template));
2989 VERIFY_BOOL_ON, template));
2993 VERIFY_RECOVER_BOOL_ON, template));
2997 WRAP_BOOL_ON, template));
3019 template, copy, sp));
3039 CK_ATTRIBUTE_PTR template, boolean_t copy, kernel_session_t *sp)
3043 switch (template->type) {
3047 CKA_SUBJECT, template));
3053 if (((*(CK_BBOOL *)template->pValue) == B_FALSE) &&
3058 if (*(CK_BBOOL *)template->pValue)
3064 DECRYPT_BOOL_ON, template));
3068 SIGN_BOOL_ON, template));
3072 SIGN_RECOVER_BOOL_ON, template));
3076 UNWRAP_BOOL_ON, template));
3082 if ((*(CK_BBOOL *)template->pValue) &&
3087 if ((*(CK_BBOOL *)template->pValue) == B_FALSE)
3117 template, copy, sp));
3137 CK_ATTRIBUTE_PTR template, boolean_t copy, kernel_session_t *sp)
3141 switch (template->type) {
3147 if (((*(CK_BBOOL *)template->pValue) == B_FALSE) &&
3152 if (*(CK_BBOOL *)template->pValue)
3158 ENCRYPT_BOOL_ON, template));
3162 DECRYPT_BOOL_ON, template));
3166 SIGN_BOOL_ON, template));
3170 VERIFY_BOOL_ON, template));
3174 WRAP_BOOL_ON, template));
3178 UNWRAP_BOOL_ON, template));
3184 if ((*(CK_BBOOL *)template->pValue) &&
3189 if ((*(CK_BBOOL *)template->pValue) == B_FALSE)
3209 template, copy, sp));
3230 kernel_set_attribute(kernel_object_t *object_p, CK_ATTRIBUTE_PTR template,
3240 rv = kernel_set_public_key_attribute(object_p, template,
3245 rv = kernel_set_private_key_attribute(object_p, template,
3250 rv = kernel_set_secret_key_attribute(object_p, template,
3256 * If the template specifies a value of an attribute
3567 * attributes on template .
3570 * of these attributes are in the template, make a list of classes
3701 CK_ULONG num_pclasses, CK_ATTRIBUTE *template, CK_ULONG num_attr)
3731 tmpl_attr = &(template[i]);
4095 * this case, it only matches the template's
4096 * attribute if the template's value length