Lines Matching refs:rc

93 	enum pkcs11_rc rc = PKCS11_CKR_OPERATION_NOT_INITIALIZED;  in get_active_session()  local
97 rc = PKCS11_CKR_OK; in get_active_session()
99 return rc; in get_active_session()
175 enum pkcs11_rc rc = PKCS11_CKR_GENERAL_ERROR; in generate_random_key_value() local
184 rc = get_attribute_ptr(*head, PKCS11_CKA_VALUE_LEN, &data, &data_size); in generate_random_key_value()
185 if (rc || data_size != sizeof(uint32_t)) { in generate_random_key_value()
186 DMSG("%s", rc ? "No attribute value_len found" : in generate_random_key_value()
194 rc = remove_empty_attribute(head, PKCS11_CKA_VALUE); in generate_random_key_value()
195 if (rc != PKCS11_CKR_OK && rc != PKCS11_RV_NOT_FOUND) in generate_random_key_value()
204 rc = add_attribute(head, PKCS11_CKA_VALUE, value, value_len); in generate_random_key_value()
206 if (rc == PKCS11_CKR_OK) in generate_random_key_value()
207 rc = set_check_value_attr(head); in generate_random_key_value()
211 return rc; in generate_random_key_value()
223 enum pkcs11_rc rc = PKCS11_CKR_GENERAL_ERROR; in entry_generate_secret() local
238 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_generate_secret()
239 if (rc) in entry_generate_secret()
240 return rc; in entry_generate_secret()
242 rc = serialargs_alloc_get_one_attribute(&ctrlargs, &proc_params); in entry_generate_secret()
243 if (rc) in entry_generate_secret()
246 rc = serialargs_alloc_get_attributes(&ctrlargs, &template); in entry_generate_secret()
247 if (rc) in entry_generate_secret()
251 rc = PKCS11_CKR_ARGUMENTS_BAD; in entry_generate_secret()
255 rc = get_ready_session(session); in entry_generate_secret()
256 if (rc) in entry_generate_secret()
261 rc = check_mechanism_against_processing(session, proc_params->id, in entry_generate_secret()
264 if (rc) { in entry_generate_secret()
265 DMSG("Invalid mechanism %#"PRIx32": %#x", proc_params->id, rc); in entry_generate_secret()
273 rc = create_attributes_from_template(&head, template, template_size, in entry_generate_secret()
277 if (rc) in entry_generate_secret()
283 rc = check_created_attrs(head, NULL); in entry_generate_secret()
284 if (rc) in entry_generate_secret()
287 rc = check_created_attrs_against_processing(proc_params->id, head); in entry_generate_secret()
288 if (rc) in entry_generate_secret()
291 rc = check_created_attrs_against_token(session, head); in entry_generate_secret()
292 if (rc) in entry_generate_secret()
304 rc = generate_random_key_value(&head); in entry_generate_secret()
305 if (rc) in entry_generate_secret()
310 rc = PKCS11_CKR_MECHANISM_INVALID; in entry_generate_secret()
320 rc = create_object(session, head, &obj_handle); in entry_generate_secret()
321 if (rc) in entry_generate_secret()
343 return rc; in entry_generate_secret()
378 enum pkcs11_rc rc = PKCS11_CKR_GENERAL_ERROR; in tee2pkcs_add_attribute() local
382 rc = alloc_get_tee_attribute_data(tee_obj, tee_id, &a_ptr, &a_size); in tee2pkcs_add_attribute()
383 if (rc) in tee2pkcs_add_attribute()
386 rc = add_attribute(head, pkcs11_id, a_ptr, a_size); in tee2pkcs_add_attribute()
391 if (rc) in tee2pkcs_add_attribute()
394 return rc; in tee2pkcs_add_attribute()
406 enum pkcs11_rc rc = PKCS11_CKR_GENERAL_ERROR; in entry_generate_key_pair() local
427 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_generate_key_pair()
428 if (rc) in entry_generate_key_pair()
429 return rc; in entry_generate_key_pair()
431 rc = serialargs_alloc_get_one_attribute(&ctrlargs, &proc_params); in entry_generate_key_pair()
432 if (rc) in entry_generate_key_pair()
435 rc = serialargs_alloc_get_attributes(&ctrlargs, &pub_template); in entry_generate_key_pair()
436 if (rc) in entry_generate_key_pair()
439 rc = serialargs_alloc_get_attributes(&ctrlargs, &priv_template); in entry_generate_key_pair()
440 if (rc) in entry_generate_key_pair()
444 rc = PKCS11_CKR_ARGUMENTS_BAD; in entry_generate_key_pair()
448 rc = get_ready_session(session); in entry_generate_key_pair()
449 if (rc) in entry_generate_key_pair()
452 rc = check_mechanism_against_processing(session, proc_params->id, in entry_generate_key_pair()
455 if (rc) in entry_generate_key_pair()
460 rc = create_attributes_from_template(&pub_head, pub_template, in entry_generate_key_pair()
465 if (rc) in entry_generate_key_pair()
474 rc = create_attributes_from_template(&priv_head, priv_template, in entry_generate_key_pair()
479 if (rc) in entry_generate_key_pair()
486 rc = add_missing_attribute_id(&pub_head, &priv_head); in entry_generate_key_pair()
487 if (rc) in entry_generate_key_pair()
491 rc = check_created_attrs(pub_head, priv_head); in entry_generate_key_pair()
492 if (rc) in entry_generate_key_pair()
495 rc = check_created_attrs_against_processing(proc_params->id, pub_head); in entry_generate_key_pair()
496 if (rc) in entry_generate_key_pair()
499 rc = check_created_attrs_against_processing(proc_params->id, in entry_generate_key_pair()
501 if (rc) in entry_generate_key_pair()
504 rc = check_created_attrs_against_token(session, pub_head); in entry_generate_key_pair()
505 if (rc) in entry_generate_key_pair()
508 rc = check_access_attrs_against_token(session, pub_head); in entry_generate_key_pair()
509 if (rc) in entry_generate_key_pair()
512 rc = check_created_attrs_against_token(session, priv_head); in entry_generate_key_pair()
513 if (rc) in entry_generate_key_pair()
516 rc = check_access_attrs_against_token(session, priv_head); in entry_generate_key_pair()
517 if (rc) in entry_generate_key_pair()
523 rc = generate_eddsa_keys(proc_params, &pub_head, &priv_head); in entry_generate_key_pair()
526 rc = generate_ec_keys(proc_params, &pub_head, &priv_head); in entry_generate_key_pair()
529 rc = generate_rsa_keys(proc_params, &pub_head, &priv_head); in entry_generate_key_pair()
532 rc = PKCS11_CKR_MECHANISM_INVALID; in entry_generate_key_pair()
535 if (rc) in entry_generate_key_pair()
544 rc = create_object(session, pub_head, &pubkey_handle); in entry_generate_key_pair()
545 if (rc) in entry_generate_key_pair()
556 rc = create_object(session, priv_head, &privkey_handle); in entry_generate_key_pair()
557 if (rc) in entry_generate_key_pair()
586 return rc; in entry_generate_key_pair()
606 enum pkcs11_rc rc = PKCS11_CKR_OK; in entry_processing_init() local
618 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_processing_init()
619 if (rc) in entry_processing_init()
620 return rc; in entry_processing_init()
623 rc = serialargs_get(&ctrlargs, &key_handle, sizeof(uint32_t)); in entry_processing_init()
624 if (rc) in entry_processing_init()
625 return rc; in entry_processing_init()
628 rc = serialargs_alloc_get_one_attribute(&ctrlargs, &proc_params); in entry_processing_init()
629 if (rc) in entry_processing_init()
630 return rc; in entry_processing_init()
633 rc = PKCS11_CKR_ARGUMENTS_BAD; in entry_processing_init()
637 rc = get_ready_session(session); in entry_processing_init()
638 if (rc) in entry_processing_init()
644 rc = PKCS11_CKR_KEY_HANDLE_INVALID; in entry_processing_init()
649 rc = set_processing_state(session, function, obj, NULL); in entry_processing_init()
650 if (rc) in entry_processing_init()
653 rc = check_mechanism_against_processing(session, proc_params->id, in entry_processing_init()
656 if (rc) in entry_processing_init()
660 rc = check_parent_attrs_against_processing(proc_params->id, in entry_processing_init()
663 if (rc) in entry_processing_init()
666 rc = check_access_attrs_against_token(session, in entry_processing_init()
668 if (rc) in entry_processing_init()
673 rc = init_symm_operation(session, function, proc_params, obj); in entry_processing_init()
675 rc = init_asymm_operation(session, function, proc_params, obj); in entry_processing_init()
677 rc = init_digest_operation(session, proc_params); in entry_processing_init()
679 rc = PKCS11_CKR_MECHANISM_INVALID; in entry_processing_init()
681 if (rc == PKCS11_CKR_OK) { in entry_processing_init()
688 if (rc) in entry_processing_init()
693 return rc; in entry_processing_init()
711 enum pkcs11_rc rc = PKCS11_CKR_OK; in entry_processing_step() local
724 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_processing_step()
725 if (rc) in entry_processing_step()
726 return rc; in entry_processing_step()
731 rc = serialargs_get(&ctrlargs, &key_handle, sizeof(uint32_t)); in entry_processing_step()
732 if (rc) in entry_processing_step()
733 return rc; in entry_processing_step()
739 rc = get_active_session(session, function); in entry_processing_step()
740 if (rc) in entry_processing_step()
741 return rc; in entry_processing_step()
748 rc = PKCS11_CKR_KEY_HANDLE_INVALID; in entry_processing_step()
752 rc = check_access_attrs_against_token(session, in entry_processing_step()
754 if (rc) { in entry_processing_step()
755 rc = PKCS11_CKR_KEY_HANDLE_INVALID; in entry_processing_step()
761 rc = check_mechanism_against_processing(session, mecha_type, in entry_processing_step()
763 if (rc) in entry_processing_step()
767 rc = step_symm_operation(session, function, step, in entry_processing_step()
770 rc = step_asymm_operation(session, function, step, in entry_processing_step()
773 rc = step_digest_operation(session, step, obj, ptypes, params); in entry_processing_step()
775 rc = PKCS11_CKR_MECHANISM_INVALID; in entry_processing_step()
777 if (rc == PKCS11_CKR_OK && (step == PKCS11_FUNC_STEP_UPDATE || in entry_processing_step()
785 if (rc == PKCS11_CKR_BUFFER_TOO_SMALL && in entry_processing_step()
789 if (rc == PKCS11_CKR_BUFFER_TOO_SMALL && step == PKCS11_FUNC_STEP_FINAL) in entry_processing_step()
796 if (rc != PKCS11_CKR_OK && rc != PKCS11_CKR_BUFFER_TOO_SMALL) in entry_processing_step()
801 if (rc != PKCS11_CKR_BUFFER_TOO_SMALL) in entry_processing_step()
806 return rc; in entry_processing_step()
815 enum pkcs11_rc rc = PKCS11_CKR_GENERAL_ERROR; in entry_processing_key() local
875 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_processing_key()
876 if (rc) in entry_processing_key()
877 return rc; in entry_processing_key()
879 rc = serialargs_get(&ctrlargs, &parent_handle, sizeof(uint32_t)); in entry_processing_key()
880 if (rc) in entry_processing_key()
881 return rc; in entry_processing_key()
883 rc = serialargs_alloc_get_one_attribute(&ctrlargs, &proc_params); in entry_processing_key()
884 if (rc) in entry_processing_key()
885 return rc; in entry_processing_key()
887 rc = serialargs_alloc_get_attributes(&ctrlargs, &template); in entry_processing_key()
888 if (rc) in entry_processing_key()
892 rc = PKCS11_CKR_ARGUMENTS_BAD; in entry_processing_key()
897 rc = get_ready_session(session); in entry_processing_key()
898 if (rc) in entry_processing_key()
904 rc = PKCS11_CKR_KEY_HANDLE_INVALID; in entry_processing_key()
909 rc = check_mechanism_against_processing(session, proc_params->id, in entry_processing_key()
912 if (rc) in entry_processing_key()
916 rc = set_processing_state(session, function, parent, NULL); in entry_processing_key()
917 if (rc) in entry_processing_key()
924 rc = check_parent_attrs_against_processing(proc_params->id, function, in entry_processing_key()
926 if (rc) { in entry_processing_key()
932 if (rc == PKCS11_CKR_KEY_FUNCTION_NOT_PERMITTED) { in entry_processing_key()
934 rc = in entry_processing_key()
937 rc = PKCS11_CKR_KEY_TYPE_INCONSISTENT; in entry_processing_key()
943 rc = check_access_attrs_against_token(session, parent->attributes); in entry_processing_key()
944 if (rc) in entry_processing_key()
952 rc = create_attributes_from_template(&head, template, template_size, in entry_processing_key()
957 if (rc) in entry_processing_key()
965 rc = check_created_attrs_against_processing(proc_params->id, head); in entry_processing_key()
966 if (rc) in entry_processing_key()
969 rc = check_created_attrs_against_token(session, head); in entry_processing_key()
970 if (rc) in entry_processing_key()
973 rc = check_access_attrs_against_token(session, head); in entry_processing_key()
974 if (rc) in entry_processing_key()
978 rc = init_symm_operation(session, operation, proc_params, in entry_processing_key()
980 if (rc) in entry_processing_key()
985 rc = derive_key_by_symm_enc(session, &out_buf, in entry_processing_key()
989 rc = unwrap_key_by_symm(session, in_buf, in_size, in entry_processing_key()
995 if (rc) in entry_processing_key()
1001 rc = init_asymm_operation(session, function, in entry_processing_key()
1003 if (rc) in entry_processing_key()
1006 rc = do_asymm_derivation(session, proc_params, &head); in entry_processing_key()
1007 if (!rc) in entry_processing_key()
1011 rc = init_asymm_operation(session, operation, in entry_processing_key()
1013 if (rc) in entry_processing_key()
1016 rc = unwrap_key_by_asymm(session, in_buf, in_size, in entry_processing_key()
1023 if (rc) in entry_processing_key()
1026 rc = PKCS11_CKR_MECHANISM_INVALID; in entry_processing_key()
1030 rc = set_key_data(&head, out_buf, out_size); in entry_processing_key()
1031 if (rc) in entry_processing_key()
1044 rc = create_object(session, head, &obj_handle); in entry_processing_key()
1045 if (rc) in entry_processing_key()
1070 return rc; in entry_processing_key()
1082 enum pkcs11_rc rc = PKCS11_CKR_OK; in entry_release_active_processing() local
1093 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_release_active_processing()
1094 if (rc) in entry_release_active_processing()
1095 return rc; in entry_release_active_processing()
1097 rc = serialargs_get_u32(&ctrlargs, &cmd); in entry_release_active_processing()
1106 rc = get_active_session(session, function); in entry_release_active_processing()
1107 if (rc) in entry_release_active_processing()
1108 return rc; in entry_release_active_processing()
1125 enum pkcs11_rc rc = PKCS11_CKR_GENERAL_ERROR; in entry_wrap_key() local
1147 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_wrap_key()
1148 if (rc) in entry_wrap_key()
1149 return rc; in entry_wrap_key()
1151 rc = serialargs_get(&ctrlargs, &wrapping_key_handle, sizeof(uint32_t)); in entry_wrap_key()
1152 if (rc) in entry_wrap_key()
1153 return rc; in entry_wrap_key()
1155 rc = serialargs_get(&ctrlargs, &key_handle, sizeof(uint32_t)); in entry_wrap_key()
1156 if (rc) in entry_wrap_key()
1157 return rc; in entry_wrap_key()
1159 rc = serialargs_alloc_get_one_attribute(&ctrlargs, &proc_params); in entry_wrap_key()
1160 if (rc) in entry_wrap_key()
1161 return rc; in entry_wrap_key()
1164 rc = PKCS11_CKR_ARGUMENTS_BAD; in entry_wrap_key()
1168 rc = get_ready_session(session); in entry_wrap_key()
1169 if (rc) in entry_wrap_key()
1174 rc = PKCS11_CKR_WRAPPING_KEY_HANDLE_INVALID; in entry_wrap_key()
1180 rc = PKCS11_CKR_KEY_HANDLE_INVALID; in entry_wrap_key()
1191 rc = PKCS11_CKR_WRAPPING_KEY_HANDLE_INVALID; in entry_wrap_key()
1195 rc = set_processing_state(session, function, wrapping_key, NULL); in entry_wrap_key()
1196 if (rc) in entry_wrap_key()
1200 rc = check_mechanism_against_processing(session, proc_params->id, in entry_wrap_key()
1203 if (rc) in entry_wrap_key()
1210 rc = check_parent_attrs_against_processing(proc_params->id, function, in entry_wrap_key()
1212 if (rc) { in entry_wrap_key()
1218 if (rc == PKCS11_CKR_KEY_FUNCTION_NOT_PERMITTED) in entry_wrap_key()
1219 rc = PKCS11_CKR_WRAPPING_KEY_TYPE_INCONSISTENT; in entry_wrap_key()
1225 rc = check_access_attrs_against_token(session, in entry_wrap_key()
1227 if (rc) in entry_wrap_key()
1235 rc = PKCS11_CKR_KEY_NOT_WRAPPABLE; in entry_wrap_key()
1242 rc = PKCS11_CKR_KEY_UNEXTRACTABLE; in entry_wrap_key()
1249 rc = PKCS11_CKR_KEY_NOT_WRAPPABLE; in entry_wrap_key()
1253 rc = check_access_attrs_against_token(session, key->attributes); in entry_wrap_key()
1254 if (rc) in entry_wrap_key()
1257 rc = get_attribute_ptr(wrapping_key->attributes, in entry_wrap_key()
1259 if (rc == PKCS11_CKR_OK && size != 0) { in entry_wrap_key()
1261 rc = PKCS11_CKR_KEY_HANDLE_INVALID; in entry_wrap_key()
1266 rc = alloc_key_data_to_wrap(key->attributes, &key_data, &key_sz); in entry_wrap_key()
1267 if (rc) in entry_wrap_key()
1271 rc = init_symm_operation(session, PKCS11_FUNCTION_ENCRYPT, in entry_wrap_key()
1273 if (rc) in entry_wrap_key()
1276 rc = wrap_data_by_symm_enc(session, key_data, key_sz, out_buf, in entry_wrap_key()
1279 rc = init_asymm_operation(session, PKCS11_FUNCTION_ENCRYPT, in entry_wrap_key()
1281 if (rc) in entry_wrap_key()
1284 rc = wrap_data_by_asymm_enc(session, key_data, key_sz, out_buf, in entry_wrap_key()
1288 if (rc == PKCS11_CKR_OK || rc == PKCS11_CKR_BUFFER_TOO_SMALL) in entry_wrap_key()
1296 return rc; in entry_wrap_key()