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()
162 enum pkcs11_rc rc = PKCS11_CKR_GENERAL_ERROR; in generate_random_key_value() local
171 rc = get_attribute_ptr(*head, PKCS11_CKA_VALUE_LEN, &data, &data_size); in generate_random_key_value()
172 if (rc || data_size != sizeof(uint32_t)) { in generate_random_key_value()
173 DMSG("%s", rc ? "No attribute value_len found" : in generate_random_key_value()
181 rc = remove_empty_attribute(head, PKCS11_CKA_VALUE); in generate_random_key_value()
182 if (rc != PKCS11_CKR_OK && rc != PKCS11_RV_NOT_FOUND) in generate_random_key_value()
191 rc = add_attribute(head, PKCS11_CKA_VALUE, value, value_len); in generate_random_key_value()
195 return rc; in generate_random_key_value()
207 enum pkcs11_rc rc = PKCS11_CKR_GENERAL_ERROR; in entry_generate_secret() local
222 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_generate_secret()
223 if (rc) in entry_generate_secret()
224 return rc; in entry_generate_secret()
226 rc = serialargs_alloc_get_one_attribute(&ctrlargs, &proc_params); in entry_generate_secret()
227 if (rc) in entry_generate_secret()
230 rc = serialargs_alloc_get_attributes(&ctrlargs, &template); in entry_generate_secret()
231 if (rc) in entry_generate_secret()
235 rc = PKCS11_CKR_ARGUMENTS_BAD; in entry_generate_secret()
239 rc = get_ready_session(session); in entry_generate_secret()
240 if (rc) in entry_generate_secret()
245 rc = check_mechanism_against_processing(session, proc_params->id, in entry_generate_secret()
248 if (rc) { in entry_generate_secret()
249 DMSG("Invalid mechanism %#"PRIx32": %#x", proc_params->id, rc); in entry_generate_secret()
257 rc = create_attributes_from_template(&head, template, template_size, in entry_generate_secret()
261 if (rc) in entry_generate_secret()
267 rc = check_created_attrs(head, NULL); in entry_generate_secret()
268 if (rc) in entry_generate_secret()
271 rc = check_created_attrs_against_processing(proc_params->id, head); in entry_generate_secret()
272 if (rc) in entry_generate_secret()
275 rc = check_created_attrs_against_token(session, head); in entry_generate_secret()
276 if (rc) in entry_generate_secret()
288 rc = generate_random_key_value(&head); in entry_generate_secret()
289 if (rc) in entry_generate_secret()
294 rc = PKCS11_CKR_MECHANISM_INVALID; in entry_generate_secret()
304 rc = create_object(session, head, &obj_handle); in entry_generate_secret()
305 if (rc) in entry_generate_secret()
327 return rc; in entry_generate_secret()
362 enum pkcs11_rc rc = PKCS11_CKR_GENERAL_ERROR; in tee2pkcs_add_attribute() local
366 rc = alloc_get_tee_attribute_data(tee_obj, tee_id, &a_ptr, &a_size); in tee2pkcs_add_attribute()
367 if (rc) in tee2pkcs_add_attribute()
370 rc = add_attribute(head, pkcs11_id, a_ptr, a_size); in tee2pkcs_add_attribute()
375 if (rc) in tee2pkcs_add_attribute()
378 return rc; in tee2pkcs_add_attribute()
390 enum pkcs11_rc rc = PKCS11_CKR_GENERAL_ERROR; in entry_generate_key_pair() local
411 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_generate_key_pair()
412 if (rc) in entry_generate_key_pair()
413 return rc; in entry_generate_key_pair()
415 rc = serialargs_alloc_get_one_attribute(&ctrlargs, &proc_params); in entry_generate_key_pair()
416 if (rc) in entry_generate_key_pair()
419 rc = serialargs_alloc_get_attributes(&ctrlargs, &pub_template); in entry_generate_key_pair()
420 if (rc) in entry_generate_key_pair()
423 rc = serialargs_alloc_get_attributes(&ctrlargs, &priv_template); in entry_generate_key_pair()
424 if (rc) in entry_generate_key_pair()
428 rc = PKCS11_CKR_ARGUMENTS_BAD; in entry_generate_key_pair()
432 rc = get_ready_session(session); in entry_generate_key_pair()
433 if (rc) in entry_generate_key_pair()
436 rc = check_mechanism_against_processing(session, proc_params->id, in entry_generate_key_pair()
439 if (rc) in entry_generate_key_pair()
444 rc = create_attributes_from_template(&pub_head, pub_template, in entry_generate_key_pair()
449 if (rc) in entry_generate_key_pair()
458 rc = create_attributes_from_template(&priv_head, priv_template, in entry_generate_key_pair()
463 if (rc) in entry_generate_key_pair()
470 rc = add_missing_attribute_id(&pub_head, &priv_head); in entry_generate_key_pair()
471 if (rc) in entry_generate_key_pair()
475 rc = check_created_attrs(pub_head, priv_head); in entry_generate_key_pair()
476 if (rc) in entry_generate_key_pair()
479 rc = check_created_attrs_against_processing(proc_params->id, pub_head); in entry_generate_key_pair()
480 if (rc) in entry_generate_key_pair()
483 rc = check_created_attrs_against_processing(proc_params->id, in entry_generate_key_pair()
485 if (rc) in entry_generate_key_pair()
488 rc = check_created_attrs_against_token(session, pub_head); in entry_generate_key_pair()
489 if (rc) in entry_generate_key_pair()
492 rc = check_access_attrs_against_token(session, pub_head); in entry_generate_key_pair()
493 if (rc) in entry_generate_key_pair()
496 rc = check_created_attrs_against_token(session, priv_head); in entry_generate_key_pair()
497 if (rc) in entry_generate_key_pair()
500 rc = check_access_attrs_against_token(session, priv_head); in entry_generate_key_pair()
501 if (rc) in entry_generate_key_pair()
507 rc = generate_ec_keys(proc_params, &pub_head, &priv_head); in entry_generate_key_pair()
510 rc = generate_rsa_keys(proc_params, &pub_head, &priv_head); in entry_generate_key_pair()
513 rc = PKCS11_CKR_MECHANISM_INVALID; in entry_generate_key_pair()
516 if (rc) in entry_generate_key_pair()
525 rc = create_object(session, pub_head, &pubkey_handle); in entry_generate_key_pair()
526 if (rc) in entry_generate_key_pair()
537 rc = create_object(session, priv_head, &privkey_handle); in entry_generate_key_pair()
538 if (rc) in entry_generate_key_pair()
568 return rc; in entry_generate_key_pair()
588 enum pkcs11_rc rc = PKCS11_CKR_OK; in entry_processing_init() local
600 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_processing_init()
601 if (rc) in entry_processing_init()
602 return rc; in entry_processing_init()
605 rc = serialargs_get(&ctrlargs, &key_handle, sizeof(uint32_t)); in entry_processing_init()
606 if (rc) in entry_processing_init()
607 return rc; in entry_processing_init()
610 rc = serialargs_alloc_get_one_attribute(&ctrlargs, &proc_params); in entry_processing_init()
611 if (rc) in entry_processing_init()
612 return rc; in entry_processing_init()
615 rc = PKCS11_CKR_ARGUMENTS_BAD; in entry_processing_init()
619 rc = get_ready_session(session); in entry_processing_init()
620 if (rc) in entry_processing_init()
626 rc = PKCS11_CKR_KEY_HANDLE_INVALID; in entry_processing_init()
631 rc = set_processing_state(session, function, obj, NULL); in entry_processing_init()
632 if (rc) in entry_processing_init()
635 rc = check_mechanism_against_processing(session, proc_params->id, in entry_processing_init()
638 if (rc) in entry_processing_init()
642 rc = check_parent_attrs_against_processing(proc_params->id, in entry_processing_init()
645 if (rc) in entry_processing_init()
648 rc = check_access_attrs_against_token(session, in entry_processing_init()
650 if (rc) in entry_processing_init()
655 rc = init_symm_operation(session, function, proc_params, obj); in entry_processing_init()
657 rc = init_asymm_operation(session, function, proc_params, obj); in entry_processing_init()
659 rc = init_digest_operation(session, proc_params); in entry_processing_init()
661 rc = PKCS11_CKR_MECHANISM_INVALID; in entry_processing_init()
663 if (rc == PKCS11_CKR_OK) { in entry_processing_init()
671 if (rc) in entry_processing_init()
676 return rc; in entry_processing_init()
694 enum pkcs11_rc rc = PKCS11_CKR_OK; in entry_processing_step() local
707 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_processing_step()
708 if (rc) in entry_processing_step()
709 return rc; in entry_processing_step()
714 rc = serialargs_get(&ctrlargs, &key_handle, sizeof(uint32_t)); in entry_processing_step()
715 if (rc) in entry_processing_step()
716 return rc; in entry_processing_step()
722 rc = get_active_session(session, function); in entry_processing_step()
723 if (rc) in entry_processing_step()
724 return rc; in entry_processing_step()
731 rc = PKCS11_CKR_KEY_HANDLE_INVALID; in entry_processing_step()
735 rc = check_access_attrs_against_token(session, in entry_processing_step()
737 if (rc) { in entry_processing_step()
738 rc = PKCS11_CKR_KEY_HANDLE_INVALID; in entry_processing_step()
744 rc = check_mechanism_against_processing(session, mecha_type, in entry_processing_step()
746 if (rc) in entry_processing_step()
750 rc = step_symm_operation(session, function, step, in entry_processing_step()
753 rc = step_asymm_operation(session, function, step, in entry_processing_step()
756 rc = step_digest_operation(session, step, obj, ptypes, params); in entry_processing_step()
758 rc = PKCS11_CKR_MECHANISM_INVALID; in entry_processing_step()
760 if (rc == PKCS11_CKR_OK && (step == PKCS11_FUNC_STEP_UPDATE || in entry_processing_step()
768 if (rc == PKCS11_CKR_BUFFER_TOO_SMALL && in entry_processing_step()
772 if (rc == PKCS11_CKR_BUFFER_TOO_SMALL && step == PKCS11_FUNC_STEP_FINAL) in entry_processing_step()
779 if (rc != PKCS11_CKR_OK && rc != PKCS11_CKR_BUFFER_TOO_SMALL) in entry_processing_step()
784 if (rc != PKCS11_CKR_BUFFER_TOO_SMALL) in entry_processing_step()
789 return rc; in entry_processing_step()
798 enum pkcs11_rc rc = PKCS11_CKR_GENERAL_ERROR; in entry_processing_key() local
858 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_processing_key()
859 if (rc) in entry_processing_key()
860 return rc; in entry_processing_key()
862 rc = serialargs_get(&ctrlargs, &parent_handle, sizeof(uint32_t)); in entry_processing_key()
863 if (rc) in entry_processing_key()
864 return rc; in entry_processing_key()
866 rc = serialargs_alloc_get_one_attribute(&ctrlargs, &proc_params); in entry_processing_key()
867 if (rc) in entry_processing_key()
868 return rc; in entry_processing_key()
870 rc = serialargs_alloc_get_attributes(&ctrlargs, &template); in entry_processing_key()
871 if (rc) in entry_processing_key()
875 rc = PKCS11_CKR_ARGUMENTS_BAD; in entry_processing_key()
880 rc = get_ready_session(session); in entry_processing_key()
881 if (rc) in entry_processing_key()
887 rc = PKCS11_CKR_KEY_HANDLE_INVALID; in entry_processing_key()
892 rc = check_mechanism_against_processing(session, proc_params->id, in entry_processing_key()
895 if (rc) in entry_processing_key()
899 rc = set_processing_state(session, function, parent, NULL); in entry_processing_key()
900 if (rc) in entry_processing_key()
907 rc = check_parent_attrs_against_processing(proc_params->id, function, in entry_processing_key()
909 if (rc) { in entry_processing_key()
915 if (rc == PKCS11_CKR_KEY_FUNCTION_NOT_PERMITTED) { in entry_processing_key()
917 rc = in entry_processing_key()
920 rc = PKCS11_CKR_KEY_TYPE_INCONSISTENT; in entry_processing_key()
926 rc = check_access_attrs_against_token(session, parent->attributes); in entry_processing_key()
927 if (rc) in entry_processing_key()
935 rc = create_attributes_from_template(&head, template, template_size, in entry_processing_key()
940 if (rc) in entry_processing_key()
948 rc = check_created_attrs_against_processing(proc_params->id, head); in entry_processing_key()
949 if (rc) in entry_processing_key()
952 rc = check_created_attrs_against_token(session, head); in entry_processing_key()
953 if (rc) in entry_processing_key()
956 rc = check_access_attrs_against_token(session, head); in entry_processing_key()
957 if (rc) in entry_processing_key()
961 rc = init_symm_operation(session, operation, proc_params, in entry_processing_key()
963 if (rc) in entry_processing_key()
970 rc = derive_key_by_symm_enc(session, &out_buf, in entry_processing_key()
974 rc = unwrap_key_by_symm(session, in_buf, in_size, in entry_processing_key()
980 if (rc) in entry_processing_key()
983 rc = PKCS11_CKR_MECHANISM_INVALID; in entry_processing_key()
987 rc = set_key_data(&head, out_buf, out_size); in entry_processing_key()
988 if (rc) in entry_processing_key()
1000 rc = create_object(session, head, &obj_handle); in entry_processing_key()
1001 if (rc) in entry_processing_key()
1026 return rc; in entry_processing_key()
1038 enum pkcs11_rc rc = PKCS11_CKR_OK; in entry_release_active_processing() local
1049 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_release_active_processing()
1050 if (rc) in entry_release_active_processing()
1051 return rc; in entry_release_active_processing()
1053 rc = serialargs_get_u32(&ctrlargs, &cmd); in entry_release_active_processing()
1062 rc = get_active_session(session, function); in entry_release_active_processing()
1063 if (rc) in entry_release_active_processing()
1064 return rc; in entry_release_active_processing()
1081 enum pkcs11_rc rc = PKCS11_CKR_GENERAL_ERROR; in entry_wrap_key() local
1103 rc = serialargs_get_session_from_handle(&ctrlargs, client, &session); in entry_wrap_key()
1104 if (rc) in entry_wrap_key()
1105 return rc; in entry_wrap_key()
1107 rc = serialargs_get(&ctrlargs, &wrapping_key_handle, sizeof(uint32_t)); in entry_wrap_key()
1108 if (rc) in entry_wrap_key()
1109 return rc; in entry_wrap_key()
1111 rc = serialargs_get(&ctrlargs, &key_handle, sizeof(uint32_t)); in entry_wrap_key()
1112 if (rc) in entry_wrap_key()
1113 return rc; in entry_wrap_key()
1115 rc = serialargs_alloc_get_one_attribute(&ctrlargs, &proc_params); in entry_wrap_key()
1116 if (rc) in entry_wrap_key()
1117 return rc; in entry_wrap_key()
1120 rc = PKCS11_CKR_ARGUMENTS_BAD; in entry_wrap_key()
1124 rc = get_ready_session(session); in entry_wrap_key()
1125 if (rc) in entry_wrap_key()
1130 rc = PKCS11_CKR_WRAPPING_KEY_HANDLE_INVALID; in entry_wrap_key()
1136 rc = PKCS11_CKR_KEY_HANDLE_INVALID; in entry_wrap_key()
1147 rc = PKCS11_CKR_WRAPPING_KEY_HANDLE_INVALID; in entry_wrap_key()
1151 rc = set_processing_state(session, function, wrapping_key, NULL); in entry_wrap_key()
1152 if (rc) in entry_wrap_key()
1156 rc = check_mechanism_against_processing(session, proc_params->id, in entry_wrap_key()
1159 if (rc) in entry_wrap_key()
1166 rc = check_parent_attrs_against_processing(proc_params->id, function, in entry_wrap_key()
1168 if (rc) { in entry_wrap_key()
1174 if (rc == PKCS11_CKR_KEY_FUNCTION_NOT_PERMITTED) in entry_wrap_key()
1175 rc = PKCS11_CKR_WRAPPING_KEY_TYPE_INCONSISTENT; in entry_wrap_key()
1181 rc = check_access_attrs_against_token(session, in entry_wrap_key()
1183 if (rc) in entry_wrap_key()
1192 rc = PKCS11_CKR_KEY_NOT_WRAPPABLE; in entry_wrap_key()
1199 rc = PKCS11_CKR_KEY_UNEXTRACTABLE; in entry_wrap_key()
1206 rc = PKCS11_CKR_KEY_NOT_WRAPPABLE; in entry_wrap_key()
1210 rc = check_access_attrs_against_token(session, key->attributes); in entry_wrap_key()
1211 if (rc) in entry_wrap_key()
1214 rc = get_attribute_ptr(wrapping_key->attributes, in entry_wrap_key()
1216 if (rc == PKCS11_CKR_OK && size != 0) { in entry_wrap_key()
1218 rc = PKCS11_CKR_KEY_HANDLE_INVALID; in entry_wrap_key()
1223 rc = get_key_data_to_wrap(key->attributes, &key_data, &key_sz); in entry_wrap_key()
1224 if (rc) in entry_wrap_key()
1228 rc = init_symm_operation(session, PKCS11_FUNCTION_ENCRYPT, in entry_wrap_key()
1230 if (rc) in entry_wrap_key()
1235 rc = wrap_data_by_symm_enc(session, key_data, key_sz, out_buf, in entry_wrap_key()
1238 rc = PKCS11_CKR_MECHANISM_INVALID; in entry_wrap_key()
1241 if (rc == PKCS11_CKR_OK || rc == PKCS11_CKR_BUFFER_TOO_SMALL) in entry_wrap_key()
1248 return rc; in entry_wrap_key()