Lines Matching refs:ret
63 int ret; in TSS_sha1() local
71 ret = crypto_shash_digest(&sdesc->shash, data, datalen, digest); in TSS_sha1()
73 return ret; in TSS_sha1()
83 int ret; in TSS_rawhmac() local
91 ret = crypto_shash_setkey(hmacalg, key, keylen); in TSS_rawhmac()
92 if (ret < 0) in TSS_rawhmac()
94 ret = crypto_shash_init(&sdesc->shash); in TSS_rawhmac()
95 if (ret < 0) in TSS_rawhmac()
105 ret = -EINVAL; in TSS_rawhmac()
108 ret = crypto_shash_update(&sdesc->shash, data, dlen); in TSS_rawhmac()
109 if (ret < 0) in TSS_rawhmac()
113 if (!ret) in TSS_rawhmac()
114 ret = crypto_shash_final(&sdesc->shash, digest); in TSS_rawhmac()
117 return ret; in TSS_rawhmac()
132 int ret; in TSS_authhmac() local
142 ret = crypto_shash_init(&sdesc->shash); in TSS_authhmac()
143 if (ret < 0) in TSS_authhmac()
152 ret = -EINVAL; in TSS_authhmac()
155 ret = crypto_shash_update(&sdesc->shash, data, dlen); in TSS_authhmac()
156 if (ret < 0) in TSS_authhmac()
160 if (!ret) in TSS_authhmac()
161 ret = crypto_shash_final(&sdesc->shash, paramdigest); in TSS_authhmac()
162 if (!ret) in TSS_authhmac()
163 ret = TSS_rawhmac(digest, key, keylen, SHA1_DIGEST_SIZE, in TSS_authhmac()
168 return ret; in TSS_authhmac()
193 int ret; in TSS_checkhmac1() local
212 ret = crypto_shash_init(&sdesc->shash); in TSS_checkhmac1()
213 if (ret < 0) in TSS_checkhmac1()
215 ret = crypto_shash_update(&sdesc->shash, (const u8 *)&result, in TSS_checkhmac1()
217 if (ret < 0) in TSS_checkhmac1()
219 ret = crypto_shash_update(&sdesc->shash, (const u8 *)&ordinal, in TSS_checkhmac1()
221 if (ret < 0) in TSS_checkhmac1()
229 ret = crypto_shash_update(&sdesc->shash, buffer + dpos, dlen); in TSS_checkhmac1()
230 if (ret < 0) in TSS_checkhmac1()
234 if (!ret) in TSS_checkhmac1()
235 ret = crypto_shash_final(&sdesc->shash, paramdigest); in TSS_checkhmac1()
236 if (ret < 0) in TSS_checkhmac1()
239 ret = TSS_rawhmac(testhmac, key, keylen, SHA1_DIGEST_SIZE, paramdigest, in TSS_checkhmac1()
242 if (ret < 0) in TSS_checkhmac1()
246 ret = -EINVAL; in TSS_checkhmac1()
249 return ret; in TSS_checkhmac1()
280 int ret; in TSS_checkhmac2() local
304 ret = crypto_shash_init(&sdesc->shash); in TSS_checkhmac2()
305 if (ret < 0) in TSS_checkhmac2()
307 ret = crypto_shash_update(&sdesc->shash, (const u8 *)&result, in TSS_checkhmac2()
309 if (ret < 0) in TSS_checkhmac2()
311 ret = crypto_shash_update(&sdesc->shash, (const u8 *)&ordinal, in TSS_checkhmac2()
313 if (ret < 0) in TSS_checkhmac2()
322 ret = crypto_shash_update(&sdesc->shash, buffer + dpos, dlen); in TSS_checkhmac2()
323 if (ret < 0) in TSS_checkhmac2()
327 if (!ret) in TSS_checkhmac2()
328 ret = crypto_shash_final(&sdesc->shash, paramdigest); in TSS_checkhmac2()
329 if (ret < 0) in TSS_checkhmac2()
332 ret = TSS_rawhmac(testhmac1, key1, keylen1, SHA1_DIGEST_SIZE, in TSS_checkhmac2()
335 if (ret < 0) in TSS_checkhmac2()
338 ret = -EINVAL; in TSS_checkhmac2()
341 ret = TSS_rawhmac(testhmac2, key2, keylen2, SHA1_DIGEST_SIZE, in TSS_checkhmac2()
344 if (ret < 0) in TSS_checkhmac2()
347 ret = -EINVAL; in TSS_checkhmac2()
350 return ret; in TSS_checkhmac2()
380 int ret; in pcrlock() local
384 ret = tpm_get_random(TPM_ANY_NUM, hash, SHA1_DIGEST_SIZE); in pcrlock()
385 if (ret != SHA1_DIGEST_SIZE) in pcrlock()
386 return ret; in pcrlock()
398 int ret; in osap() local
400 ret = tpm_get_random(TPM_ANY_NUM, ononce, TPM_NONCE_SIZE); in osap()
401 if (ret != TPM_NONCE_SIZE) in osap()
402 return ret; in osap()
412 ret = trusted_tpm_send(TPM_ANY_NUM, tb->data, MAX_BUF_SIZE); in osap()
413 if (ret < 0) in osap()
414 return ret; in osap()
430 int ret; in oiap() local
436 ret = trusted_tpm_send(TPM_ANY_NUM, tb->data, MAX_BUF_SIZE); in oiap()
437 if (ret < 0) in oiap()
438 return ret; in oiap()
474 int ret; in tpm_seal() local
483 ret = osap(tb, &sess, keyauth, keytype, keyhandle); in tpm_seal()
484 if (ret < 0) in tpm_seal()
491 ret = TSS_sha1(td->xorwork, SHA1_DIGEST_SIZE * 2, td->xorhash); in tpm_seal()
492 if (ret < 0) in tpm_seal()
495 ret = tpm_get_random(TPM_ANY_NUM, td->nonceodd, TPM_NONCE_SIZE); in tpm_seal()
496 if (ret != TPM_NONCE_SIZE) in tpm_seal()
510 ret = TSS_authhmac(td->pubauth, sess.secret, SHA1_DIGEST_SIZE, in tpm_seal()
518 ret = TSS_authhmac(td->pubauth, sess.secret, SHA1_DIGEST_SIZE, in tpm_seal()
525 if (ret < 0) in tpm_seal()
544 ret = trusted_tpm_send(TPM_ANY_NUM, tb->data, MAX_BUF_SIZE); in tpm_seal()
545 if (ret < 0) in tpm_seal()
556 ret = TSS_checkhmac1(tb->data, ordinal, td->nonceodd, sess.secret, in tpm_seal()
561 if (!ret) { in tpm_seal()
567 return ret; in tpm_seal()
589 int ret; in tpm_unseal() local
592 ret = oiap(tb, &authhandle1, enonce1); in tpm_unseal()
593 if (ret < 0) { in tpm_unseal()
594 pr_info("trusted_key: oiap failed (%d)\n", ret); in tpm_unseal()
595 return ret; in tpm_unseal()
597 ret = oiap(tb, &authhandle2, enonce2); in tpm_unseal()
598 if (ret < 0) { in tpm_unseal()
599 pr_info("trusted_key: oiap failed (%d)\n", ret); in tpm_unseal()
600 return ret; in tpm_unseal()
605 ret = tpm_get_random(TPM_ANY_NUM, nonceodd, TPM_NONCE_SIZE); in tpm_unseal()
606 if (ret != TPM_NONCE_SIZE) { in tpm_unseal()
607 pr_info("trusted_key: tpm_get_random failed (%d)\n", ret); in tpm_unseal()
608 return ret; in tpm_unseal()
610 ret = TSS_authhmac(authdata1, keyauth, TPM_NONCE_SIZE, in tpm_unseal()
613 if (ret < 0) in tpm_unseal()
614 return ret; in tpm_unseal()
615 ret = TSS_authhmac(authdata2, blobauth, TPM_NONCE_SIZE, in tpm_unseal()
618 if (ret < 0) in tpm_unseal()
619 return ret; in tpm_unseal()
637 ret = trusted_tpm_send(TPM_ANY_NUM, tb->data, MAX_BUF_SIZE); in tpm_unseal()
638 if (ret < 0) { in tpm_unseal()
639 pr_info("trusted_key: authhmac failed (%d)\n", ret); in tpm_unseal()
640 return ret; in tpm_unseal()
644 ret = TSS_checkhmac2(tb->data, ordinal, nonceodd, in tpm_unseal()
650 if (ret < 0) { in tpm_unseal()
651 pr_info("trusted_key: TSS_checkhmac2 failed (%d)\n", ret); in tpm_unseal()
652 return ret; in tpm_unseal()
665 int ret; in key_seal() local
674 ret = tpm_seal(tb, o->keytype, o->keyhandle, o->keyauth, in key_seal()
677 if (ret < 0) in key_seal()
678 pr_info("trusted_key: srkseal failed (%d)\n", ret); in key_seal()
681 return ret; in key_seal()
691 int ret; in key_unseal() local
697 ret = tpm_unseal(tb, o->keyhandle, o->keyauth, p->blob, p->blob_len, in key_unseal()
699 if (ret < 0) in key_unseal()
700 pr_info("trusted_key: srkunseal failed (%d)\n", ret); in key_unseal()
706 return ret; in key_unseal()
808 int ret = -EINVAL; in datablob_parse() local
823 ret = kstrtol(c, 10, &keylen); in datablob_parse()
824 if (ret < 0 || keylen < MIN_KEY_SIZE || keylen > MAX_KEY_SIZE) in datablob_parse()
827 ret = getoptions(datablob, p, o); in datablob_parse()
828 if (ret < 0) in datablob_parse()
829 return ret; in datablob_parse()
830 ret = Opt_new; in datablob_parse()
840 ret = hex2bin(p->blob, c, p->blob_len); in datablob_parse()
841 if (ret < 0) in datablob_parse()
843 ret = getoptions(datablob, p, o); in datablob_parse()
844 if (ret < 0) in datablob_parse()
845 return ret; in datablob_parse()
846 ret = Opt_load; in datablob_parse()
850 ret = getoptions(datablob, p, o); in datablob_parse()
851 if (ret < 0) in datablob_parse()
852 return ret; in datablob_parse()
853 ret = Opt_update; in datablob_parse()
859 return ret; in datablob_parse()
885 int ret; in trusted_payload_alloc() local
887 ret = key_payload_reserve(key, sizeof *p); in trusted_payload_alloc()
888 if (ret < 0) in trusted_payload_alloc()
912 int ret = 0; in trusted_instantiate() local
932 ret = -ENOMEM; in trusted_instantiate()
937 ret = -ENOMEM; in trusted_instantiate()
943 ret = key_cmd; in trusted_instantiate()
948 ret = -EINVAL; in trusted_instantiate()
958 ret = tpm_unseal_trusted(TPM_ANY_NUM, payload, options); in trusted_instantiate()
960 ret = key_unseal(payload, options); in trusted_instantiate()
963 if (ret < 0) in trusted_instantiate()
964 pr_info("trusted_key: key_unseal failed (%d)\n", ret); in trusted_instantiate()
968 ret = tpm_get_random(TPM_ANY_NUM, payload->key, key_len); in trusted_instantiate()
969 if (ret != key_len) { in trusted_instantiate()
970 pr_info("trusted_key: key_create failed (%d)\n", ret); in trusted_instantiate()
974 ret = tpm_seal_trusted(TPM_ANY_NUM, payload, options); in trusted_instantiate()
976 ret = key_seal(payload, options); in trusted_instantiate()
977 if (ret < 0) in trusted_instantiate()
978 pr_info("trusted_key: key_seal failed (%d)\n", ret); in trusted_instantiate()
981 ret = -EINVAL; in trusted_instantiate()
984 if (!ret && options->pcrlock) in trusted_instantiate()
985 ret = pcrlock(options->pcrlock); in trusted_instantiate()
989 if (!ret) in trusted_instantiate()
993 return ret; in trusted_instantiate()
1015 int ret = 0; in trusted_update() local
1030 ret = -ENOMEM; in trusted_update()
1035 ret = -ENOMEM; in trusted_update()
1041 ret = datablob_parse(datablob, new_p, new_o); in trusted_update()
1042 if (ret != Opt_update) { in trusted_update()
1043 ret = -EINVAL; in trusted_update()
1049 ret = -EINVAL; in trusted_update()
1061 ret = key_seal(new_p, new_o); in trusted_update()
1062 if (ret < 0) { in trusted_update()
1063 pr_info("trusted_key: key_seal failed (%d)\n", ret); in trusted_update()
1068 ret = pcrlock(new_o->pcrlock); in trusted_update()
1069 if (ret < 0) { in trusted_update()
1070 pr_info("trusted_key: pcrlock failed (%d)\n", ret); in trusted_update()
1080 return ret; in trusted_update()
1149 int ret; in trusted_shash_alloc() local
1162 ret = PTR_ERR(hashalg); in trusted_shash_alloc()
1170 return ret; in trusted_shash_alloc()
1175 int ret; in init_trusted() local
1177 ret = trusted_shash_alloc(); in init_trusted()
1178 if (ret < 0) in init_trusted()
1179 return ret; in init_trusted()
1180 ret = register_key_type(&key_type_trusted); in init_trusted()
1181 if (ret < 0) in init_trusted()
1183 return ret; in init_trusted()