1 // SPDX-License-Identifier: BSD-2-Clause 2 /* 3 * Copyright (c) 2017, Linaro Limited 4 * Copyright 2020 NXP 5 */ 6 7 #include <assert.h> 8 #include <compiler.h> 9 #include <crypto/crypto.h> 10 #include <crypto/crypto_impl.h> 11 #include <kernel/panic.h> 12 #include <stdlib.h> 13 #include <string.h> 14 #include <utee_defines.h> 15 16 TEE_Result crypto_hash_alloc_ctx(void **ctx, uint32_t algo) 17 { 18 TEE_Result res = TEE_ERROR_NOT_IMPLEMENTED; 19 struct crypto_hash_ctx *c = NULL; 20 21 /* 22 * Use default cryptographic implementation if no matching 23 * drvcrypt device. 24 */ 25 res = drvcrypt_hash_alloc_ctx(&c, algo); 26 27 if (res == TEE_ERROR_NOT_IMPLEMENTED) { 28 switch (algo) { 29 case TEE_ALG_MD5: 30 res = crypto_md5_alloc_ctx(&c); 31 break; 32 case TEE_ALG_SHA1: 33 res = crypto_sha1_alloc_ctx(&c); 34 break; 35 case TEE_ALG_SHA224: 36 res = crypto_sha224_alloc_ctx(&c); 37 break; 38 case TEE_ALG_SHA256: 39 res = crypto_sha256_alloc_ctx(&c); 40 break; 41 case TEE_ALG_SHA384: 42 res = crypto_sha384_alloc_ctx(&c); 43 break; 44 case TEE_ALG_SHA512: 45 res = crypto_sha512_alloc_ctx(&c); 46 break; 47 case TEE_ALG_SM3: 48 res = crypto_sm3_alloc_ctx(&c); 49 break; 50 default: 51 break; 52 } 53 } 54 55 if (!res) 56 *ctx = c; 57 58 return res; 59 } 60 61 static const struct crypto_hash_ops *hash_ops(void *ctx) 62 { 63 struct crypto_hash_ctx *c = ctx; 64 65 assert(c && c->ops); 66 67 return c->ops; 68 } 69 70 void crypto_hash_free_ctx(void *ctx) 71 { 72 if (ctx) 73 hash_ops(ctx)->free_ctx(ctx); 74 } 75 76 void crypto_hash_copy_state(void *dst_ctx, void *src_ctx) 77 { 78 hash_ops(dst_ctx)->copy_state(dst_ctx, src_ctx); 79 } 80 81 TEE_Result crypto_hash_init(void *ctx) 82 { 83 return hash_ops(ctx)->init(ctx); 84 } 85 86 TEE_Result crypto_hash_update(void *ctx, const uint8_t *data, size_t len) 87 { 88 return hash_ops(ctx)->update(ctx, data, len); 89 } 90 91 TEE_Result crypto_hash_final(void *ctx, uint8_t *digest, size_t len) 92 { 93 return hash_ops(ctx)->final(ctx, digest, len); 94 } 95 96 TEE_Result crypto_cipher_alloc_ctx(void **ctx, uint32_t algo) 97 { 98 TEE_Result res = TEE_ERROR_NOT_IMPLEMENTED; 99 struct crypto_cipher_ctx *c = NULL; 100 101 /* 102 * Use default cryptographic implementation if no matching 103 * drvcrypt device. 104 */ 105 res = drvcrypt_cipher_alloc_ctx(&c, algo); 106 107 if (res == TEE_ERROR_NOT_IMPLEMENTED) { 108 switch (algo) { 109 case TEE_ALG_AES_ECB_NOPAD: 110 res = crypto_aes_ecb_alloc_ctx(&c); 111 break; 112 case TEE_ALG_AES_CBC_NOPAD: 113 res = crypto_aes_cbc_alloc_ctx(&c); 114 break; 115 case TEE_ALG_AES_CTR: 116 res = crypto_aes_ctr_alloc_ctx(&c); 117 break; 118 case TEE_ALG_AES_CTS: 119 res = crypto_aes_cts_alloc_ctx(&c); 120 break; 121 case TEE_ALG_AES_XTS: 122 res = crypto_aes_xts_alloc_ctx(&c); 123 break; 124 case TEE_ALG_DES_ECB_NOPAD: 125 res = crypto_des_ecb_alloc_ctx(&c); 126 break; 127 case TEE_ALG_DES3_ECB_NOPAD: 128 res = crypto_des3_ecb_alloc_ctx(&c); 129 break; 130 case TEE_ALG_DES_CBC_NOPAD: 131 res = crypto_des_cbc_alloc_ctx(&c); 132 break; 133 case TEE_ALG_DES3_CBC_NOPAD: 134 res = crypto_des3_cbc_alloc_ctx(&c); 135 break; 136 case TEE_ALG_SM4_ECB_NOPAD: 137 res = crypto_sm4_ecb_alloc_ctx(&c); 138 break; 139 case TEE_ALG_SM4_CBC_NOPAD: 140 res = crypto_sm4_cbc_alloc_ctx(&c); 141 break; 142 case TEE_ALG_SM4_CTR: 143 res = crypto_sm4_ctr_alloc_ctx(&c); 144 break; 145 default: 146 return TEE_ERROR_NOT_IMPLEMENTED; 147 } 148 } 149 150 if (!res) 151 *ctx = c; 152 153 return res; 154 } 155 156 static const struct crypto_cipher_ops *cipher_ops(void *ctx) 157 { 158 struct crypto_cipher_ctx *c = ctx; 159 160 assert(c && c->ops); 161 162 return c->ops; 163 } 164 165 void crypto_cipher_free_ctx(void *ctx) 166 { 167 if (ctx) 168 cipher_ops(ctx)->free_ctx(ctx); 169 } 170 171 void crypto_cipher_copy_state(void *dst_ctx, void *src_ctx) 172 { 173 cipher_ops(dst_ctx)->copy_state(dst_ctx, src_ctx); 174 } 175 176 TEE_Result crypto_cipher_init(void *ctx, TEE_OperationMode mode, 177 const uint8_t *key1, size_t key1_len, 178 const uint8_t *key2, size_t key2_len, 179 const uint8_t *iv, size_t iv_len) 180 { 181 if (mode != TEE_MODE_DECRYPT && mode != TEE_MODE_ENCRYPT) 182 return TEE_ERROR_BAD_PARAMETERS; 183 184 return cipher_ops(ctx)->init(ctx, mode, key1, key1_len, key2, key2_len, 185 iv, iv_len); 186 } 187 188 TEE_Result crypto_cipher_update(void *ctx, TEE_OperationMode mode __unused, 189 bool last_block, const uint8_t *data, 190 size_t len, uint8_t *dst) 191 { 192 return cipher_ops(ctx)->update(ctx, last_block, data, len, dst); 193 } 194 195 void crypto_cipher_final(void *ctx) 196 { 197 cipher_ops(ctx)->final(ctx); 198 } 199 200 TEE_Result crypto_cipher_get_block_size(uint32_t algo, size_t *size) 201 { 202 uint32_t class = TEE_ALG_GET_CLASS(algo); 203 204 if (class != TEE_OPERATION_CIPHER && class != TEE_OPERATION_MAC && 205 class != TEE_OPERATION_AE) 206 return TEE_ERROR_BAD_PARAMETERS; 207 208 switch (TEE_ALG_GET_MAIN_ALG(algo)) { 209 case TEE_MAIN_ALGO_AES: 210 *size = TEE_AES_BLOCK_SIZE; 211 return TEE_SUCCESS; 212 case TEE_MAIN_ALGO_DES: 213 case TEE_MAIN_ALGO_DES3: 214 *size = TEE_DES_BLOCK_SIZE; 215 return TEE_SUCCESS; 216 case TEE_MAIN_ALGO_SM4: 217 *size = TEE_SM4_BLOCK_SIZE; 218 return TEE_SUCCESS; 219 default: 220 return TEE_ERROR_NOT_SUPPORTED; 221 } 222 } 223 224 TEE_Result crypto_mac_alloc_ctx(void **ctx, uint32_t algo) 225 { 226 TEE_Result res = TEE_SUCCESS; 227 struct crypto_mac_ctx *c = NULL; 228 229 switch (algo) { 230 case TEE_ALG_HMAC_MD5: 231 res = crypto_hmac_md5_alloc_ctx(&c); 232 break; 233 case TEE_ALG_HMAC_SHA1: 234 res = crypto_hmac_sha1_alloc_ctx(&c); 235 break; 236 case TEE_ALG_HMAC_SHA224: 237 res = crypto_hmac_sha224_alloc_ctx(&c); 238 break; 239 case TEE_ALG_HMAC_SHA256: 240 res = crypto_hmac_sha256_alloc_ctx(&c); 241 break; 242 case TEE_ALG_HMAC_SHA384: 243 res = crypto_hmac_sha384_alloc_ctx(&c); 244 break; 245 case TEE_ALG_HMAC_SHA512: 246 res = crypto_hmac_sha512_alloc_ctx(&c); 247 break; 248 case TEE_ALG_HMAC_SM3: 249 res = crypto_hmac_sm3_alloc_ctx(&c); 250 break; 251 case TEE_ALG_AES_CBC_MAC_NOPAD: 252 res = crypto_aes_cbc_mac_nopad_alloc_ctx(&c); 253 break; 254 case TEE_ALG_AES_CBC_MAC_PKCS5: 255 res = crypto_aes_cbc_mac_pkcs5_alloc_ctx(&c); 256 break; 257 case TEE_ALG_DES_CBC_MAC_NOPAD: 258 res = crypto_des_cbc_mac_nopad_alloc_ctx(&c); 259 break; 260 case TEE_ALG_DES_CBC_MAC_PKCS5: 261 res = crypto_des_cbc_mac_pkcs5_alloc_ctx(&c); 262 break; 263 case TEE_ALG_DES3_CBC_MAC_NOPAD: 264 res = crypto_des3_cbc_mac_nopad_alloc_ctx(&c); 265 break; 266 case TEE_ALG_DES3_CBC_MAC_PKCS5: 267 res = crypto_des3_cbc_mac_pkcs5_alloc_ctx(&c); 268 break; 269 case TEE_ALG_AES_CMAC: 270 res = crypto_aes_cmac_alloc_ctx(&c); 271 break; 272 default: 273 return TEE_ERROR_NOT_SUPPORTED; 274 } 275 276 if (!res) 277 *ctx = c; 278 279 return res; 280 } 281 282 static const struct crypto_mac_ops *mac_ops(void *ctx) 283 { 284 struct crypto_mac_ctx *c = ctx; 285 286 assert(c && c->ops); 287 288 return c->ops; 289 } 290 291 void crypto_mac_free_ctx(void *ctx) 292 { 293 if (ctx) 294 mac_ops(ctx)->free_ctx(ctx); 295 } 296 297 void crypto_mac_copy_state(void *dst_ctx, void *src_ctx) 298 { 299 mac_ops(dst_ctx)->copy_state(dst_ctx, src_ctx); 300 } 301 302 TEE_Result crypto_mac_init(void *ctx, const uint8_t *key, size_t len) 303 { 304 return mac_ops(ctx)->init(ctx, key, len); 305 } 306 307 TEE_Result crypto_mac_update(void *ctx, const uint8_t *data, size_t len) 308 { 309 if (!len) 310 return TEE_SUCCESS; 311 312 return mac_ops(ctx)->update(ctx, data, len); 313 } 314 315 TEE_Result crypto_mac_final(void *ctx, uint8_t *digest, size_t digest_len) 316 { 317 return mac_ops(ctx)->final(ctx, digest, digest_len); 318 } 319 320 TEE_Result crypto_authenc_alloc_ctx(void **ctx, uint32_t algo) 321 { 322 TEE_Result res = TEE_SUCCESS; 323 struct crypto_authenc_ctx *c = NULL; 324 325 switch (algo) { 326 #if defined(CFG_CRYPTO_CCM) 327 case TEE_ALG_AES_CCM: 328 res = crypto_aes_ccm_alloc_ctx(&c); 329 break; 330 #endif 331 #if defined(CFG_CRYPTO_GCM) 332 case TEE_ALG_AES_GCM: 333 res = crypto_aes_gcm_alloc_ctx(&c); 334 break; 335 #endif 336 default: 337 return TEE_ERROR_NOT_IMPLEMENTED; 338 } 339 340 if (!res) 341 *ctx = c; 342 343 return res; 344 } 345 346 static const struct crypto_authenc_ops *ae_ops(void *ctx) 347 { 348 struct crypto_authenc_ctx *c = ctx; 349 350 assert(c && c->ops); 351 352 return c->ops; 353 } 354 355 TEE_Result crypto_authenc_init(void *ctx, TEE_OperationMode mode, 356 const uint8_t *key, size_t key_len, 357 const uint8_t *nonce, size_t nonce_len, 358 size_t tag_len, size_t aad_len, 359 size_t payload_len) 360 { 361 return ae_ops(ctx)->init(ctx, mode, key, key_len, nonce, nonce_len, 362 tag_len, aad_len, payload_len); 363 } 364 365 TEE_Result crypto_authenc_update_aad(void *ctx, TEE_OperationMode mode __unused, 366 const uint8_t *data, size_t len) 367 { 368 return ae_ops(ctx)->update_aad(ctx, data, len); 369 } 370 371 372 TEE_Result crypto_authenc_update_payload(void *ctx, TEE_OperationMode mode, 373 const uint8_t *src_data, 374 size_t src_len, uint8_t *dst_data, 375 size_t *dst_len) 376 { 377 if (*dst_len < src_len) 378 return TEE_ERROR_SHORT_BUFFER; 379 *dst_len = src_len; 380 381 return ae_ops(ctx)->update_payload(ctx, mode, src_data, src_len, 382 dst_data); 383 } 384 385 TEE_Result crypto_authenc_enc_final(void *ctx, const uint8_t *src_data, 386 size_t src_len, uint8_t *dst_data, 387 size_t *dst_len, uint8_t *dst_tag, 388 size_t *dst_tag_len) 389 { 390 if (*dst_len < src_len) 391 return TEE_ERROR_SHORT_BUFFER; 392 *dst_len = src_len; 393 394 return ae_ops(ctx)->enc_final(ctx, src_data, src_len, dst_data, 395 dst_tag, dst_tag_len); 396 } 397 398 TEE_Result crypto_authenc_dec_final(void *ctx, const uint8_t *src_data, 399 size_t src_len, uint8_t *dst_data, 400 size_t *dst_len, const uint8_t *tag, 401 size_t tag_len) 402 { 403 if (*dst_len < src_len) 404 return TEE_ERROR_SHORT_BUFFER; 405 *dst_len = src_len; 406 407 return ae_ops(ctx)->dec_final(ctx, src_data, src_len, dst_data, tag, 408 tag_len); 409 } 410 411 void crypto_authenc_final(void *ctx) 412 { 413 ae_ops(ctx)->final(ctx); 414 } 415 416 void crypto_authenc_free_ctx(void *ctx) 417 { 418 if (ctx) 419 ae_ops(ctx)->free_ctx(ctx); 420 } 421 422 void crypto_authenc_copy_state(void *dst_ctx, void *src_ctx) 423 { 424 ae_ops(dst_ctx)->copy_state(dst_ctx, src_ctx); 425 } 426 427 #if !defined(CFG_CRYPTO_RSA) && !defined(CFG_CRYPTO_DSA) && \ 428 !defined(CFG_CRYPTO_DH) && !defined(CFG_CRYPTO_ECC) 429 struct bignum *crypto_bignum_allocate(size_t size_bits __unused) 430 { 431 return NULL; 432 } 433 434 TEE_Result crypto_bignum_bin2bn(const uint8_t *from __unused, 435 size_t fromsize __unused, 436 struct bignum *to __unused) 437 { 438 return TEE_ERROR_NOT_IMPLEMENTED; 439 } 440 441 size_t crypto_bignum_num_bytes(struct bignum *a __unused) 442 { 443 return 0; 444 } 445 446 size_t crypto_bignum_num_bits(struct bignum *a __unused) 447 { 448 return 0; 449 } 450 451 /* 452 * crypto_bignum_allocate() and crypto_bignum_bin2bn() failing should be 453 * enough to guarantee that the functions calling this function aren't 454 * called, but just in case add a panic() here to avoid unexpected 455 * behavoir. 456 */ 457 static void bignum_cant_happen(void) 458 { 459 volatile bool b = true; 460 461 /* Avoid warning about function does not return */ 462 if (b) 463 panic(); 464 } 465 466 void crypto_bignum_bn2bin(const struct bignum *from __unused, 467 uint8_t *to __unused) 468 { 469 bignum_cant_happen(); 470 } 471 472 void crypto_bignum_copy(struct bignum *to __unused, 473 const struct bignum *from __unused) 474 { 475 bignum_cant_happen(); 476 } 477 478 void crypto_bignum_free(struct bignum *a) 479 { 480 if (a) 481 panic(); 482 } 483 484 void crypto_bignum_clear(struct bignum *a __unused) 485 { 486 bignum_cant_happen(); 487 } 488 489 /* return -1 if a<b, 0 if a==b, +1 if a>b */ 490 int32_t crypto_bignum_compare(struct bignum *a __unused, 491 struct bignum *b __unused) 492 { 493 bignum_cant_happen(); 494 return -1; 495 } 496 #endif 497 498 #if !defined(CFG_CRYPTO_RSA) 499 TEE_Result crypto_acipher_alloc_rsa_keypair(struct rsa_keypair *s __unused, 500 size_t key_size_bits __unused) 501 { 502 return TEE_ERROR_NOT_IMPLEMENTED; 503 } 504 505 TEE_Result 506 crypto_acipher_alloc_rsa_public_key(struct rsa_public_key *s __unused, 507 size_t key_size_bits __unused) 508 { 509 return TEE_ERROR_NOT_IMPLEMENTED; 510 } 511 512 void crypto_acipher_free_rsa_public_key(struct rsa_public_key *s __unused) 513 { 514 } 515 516 TEE_Result crypto_acipher_gen_rsa_key(struct rsa_keypair *key __unused, 517 size_t key_size __unused) 518 { 519 return TEE_ERROR_NOT_IMPLEMENTED; 520 } 521 522 TEE_Result crypto_acipher_rsanopad_decrypt(struct rsa_keypair *key __unused, 523 const uint8_t *src __unused, 524 size_t src_len __unused, 525 uint8_t *dst __unused, 526 size_t *dst_len __unused) 527 { 528 return TEE_ERROR_NOT_IMPLEMENTED; 529 } 530 531 TEE_Result crypto_acipher_rsanopad_encrypt(struct rsa_public_key *key __unused, 532 const uint8_t *src __unused, 533 size_t src_len __unused, 534 uint8_t *dst __unused, 535 size_t *dst_len __unused) 536 { 537 return TEE_ERROR_NOT_IMPLEMENTED; 538 } 539 540 TEE_Result crypto_acipher_rsaes_decrypt(uint32_t algo __unused, 541 struct rsa_keypair *key __unused, 542 const uint8_t *label __unused, 543 size_t label_len __unused, 544 const uint8_t *src __unused, 545 size_t src_len __unused, 546 uint8_t *dst __unused, 547 size_t *dst_len __unused) 548 { 549 return TEE_ERROR_NOT_IMPLEMENTED; 550 } 551 552 TEE_Result crypto_acipher_rsaes_encrypt(uint32_t algo __unused, 553 struct rsa_public_key *key __unused, 554 const uint8_t *label __unused, 555 size_t label_len __unused, 556 const uint8_t *src __unused, 557 size_t src_len __unused, 558 uint8_t *dst __unused, 559 size_t *dst_len __unused) 560 { 561 return TEE_ERROR_NOT_IMPLEMENTED; 562 } 563 564 TEE_Result crypto_acipher_rsassa_sign(uint32_t algo __unused, 565 struct rsa_keypair *key __unused, 566 int salt_len __unused, 567 const uint8_t *msg __unused, 568 size_t msg_len __unused, 569 uint8_t *sig __unused, 570 size_t *sig_len __unused) 571 { 572 return TEE_ERROR_NOT_IMPLEMENTED; 573 } 574 575 TEE_Result crypto_acipher_rsassa_verify(uint32_t algo __unused, 576 struct rsa_public_key *key __unused, 577 int salt_len __unused, 578 const uint8_t *msg __unused, 579 size_t msg_len __unused, 580 const uint8_t *sig __unused, 581 size_t sig_len __unused) 582 { 583 return TEE_ERROR_NOT_IMPLEMENTED; 584 } 585 #endif /*!CFG_CRYPTO_RSA*/ 586 587 #if !defined(CFG_CRYPTO_DSA) 588 TEE_Result crypto_acipher_alloc_dsa_keypair(struct dsa_keypair *s __unused, 589 size_t key_size_bits __unused) 590 { 591 return TEE_ERROR_NOT_IMPLEMENTED; 592 } 593 594 TEE_Result 595 crypto_acipher_alloc_dsa_public_key(struct dsa_public_key *s __unused, 596 size_t key_size_bits __unused) 597 { 598 return TEE_ERROR_NOT_IMPLEMENTED; 599 } 600 601 TEE_Result crypto_acipher_gen_dsa_key(struct dsa_keypair *key __unused, 602 size_t key_size __unused) 603 { 604 return TEE_ERROR_NOT_IMPLEMENTED; 605 } 606 607 TEE_Result crypto_acipher_dsa_sign(uint32_t algo __unused, 608 struct dsa_keypair *key __unused, 609 const uint8_t *msg __unused, 610 size_t msg_len __unused, 611 uint8_t *sig __unused, 612 size_t *sig_len __unused) 613 { 614 return TEE_ERROR_NOT_IMPLEMENTED; 615 } 616 617 TEE_Result crypto_acipher_dsa_verify(uint32_t algo __unused, 618 struct dsa_public_key *key __unused, 619 const uint8_t *msg __unused, 620 size_t msg_len __unused, 621 const uint8_t *sig __unused, 622 size_t sig_len __unused) 623 { 624 return TEE_ERROR_NOT_IMPLEMENTED; 625 } 626 #endif /*!CFG_CRYPTO_DSA*/ 627 628 #if !defined(CFG_CRYPTO_DH) 629 TEE_Result crypto_acipher_alloc_dh_keypair(struct dh_keypair *s __unused, 630 size_t key_size_bits __unused) 631 { 632 return TEE_ERROR_NOT_IMPLEMENTED; 633 } 634 635 TEE_Result crypto_acipher_gen_dh_key(struct dh_keypair *key __unused, 636 struct bignum *q __unused, 637 size_t xbits __unused) 638 { 639 return TEE_ERROR_NOT_IMPLEMENTED; 640 } 641 642 TEE_Result 643 crypto_acipher_dh_shared_secret(struct dh_keypair *private_key __unused, 644 struct bignum *public_key __unused, 645 struct bignum *secret __unused) 646 { 647 return TEE_ERROR_NOT_IMPLEMENTED; 648 } 649 #endif /*!CFG_CRYPTO_DH*/ 650 651 #if !defined(CFG_CRYPTO_ECC) 652 TEE_Result 653 crypto_acipher_alloc_ecc_public_key(struct ecc_public_key *s __unused, 654 size_t key_size_bits __unused) 655 { 656 return TEE_ERROR_NOT_IMPLEMENTED; 657 } 658 659 TEE_Result crypto_acipher_alloc_ecc_keypair(struct ecc_keypair *s __unused, 660 size_t key_size_bits __unused) 661 { 662 return TEE_ERROR_NOT_IMPLEMENTED; 663 } 664 665 void crypto_acipher_free_ecc_public_key(struct ecc_public_key *s __unused) 666 { 667 } 668 669 TEE_Result crypto_acipher_gen_ecc_key(struct ecc_keypair *key __unused) 670 { 671 return TEE_ERROR_NOT_IMPLEMENTED; 672 } 673 674 TEE_Result crypto_acipher_ecc_sign(uint32_t algo __unused, 675 struct ecc_keypair *key __unused, 676 const uint8_t *msg __unused, 677 size_t msg_len __unused, 678 uint8_t *sig __unused, 679 size_t *sig_len __unused) 680 { 681 return TEE_ERROR_NOT_IMPLEMENTED; 682 } 683 684 TEE_Result crypto_acipher_ecc_verify(uint32_t algo __unused, 685 struct ecc_public_key *key __unused, 686 const uint8_t *msg __unused, 687 size_t msg_len __unused, 688 const uint8_t *sig __unused, 689 size_t sig_len __unused) 690 { 691 return TEE_ERROR_NOT_IMPLEMENTED; 692 } 693 694 TEE_Result 695 crypto_acipher_ecc_shared_secret(struct ecc_keypair *private_key __unused, 696 struct ecc_public_key *public_key __unused, 697 void *secret __unused, 698 unsigned long *secret_len __unused) 699 { 700 return TEE_ERROR_NOT_IMPLEMENTED; 701 } 702 #endif /*!CFG_CRYPTO_ECC*/ 703 704 #if !defined(CFG_CRYPTO_SM2_PKE) 705 TEE_Result crypto_acipher_sm2_pke_decrypt(struct ecc_keypair *key __unused, 706 const uint8_t *src __unused, 707 size_t src_len __unused, 708 uint8_t *dst __unused, 709 size_t *dst_len __unused) 710 { 711 return TEE_ERROR_NOT_IMPLEMENTED; 712 } 713 714 TEE_Result crypto_acipher_sm2_pke_encrypt(struct ecc_public_key *key __unused, 715 const uint8_t *src __unused, 716 size_t src_len __unused, 717 uint8_t *dst __unused, 718 size_t *dst_len __unused) 719 { 720 return TEE_ERROR_NOT_IMPLEMENTED; 721 } 722 #endif /* !CFG_CRYPTO_SM2_PKE */ 723 724 #if !defined(CFG_CRYPTO_SM2_DSA) 725 TEE_Result crypto_acipher_sm2_dsa_sign(uint32_t algo __unused, 726 struct ecc_keypair *key __unused, 727 const uint8_t *msg __unused, 728 size_t msg_len __unused, 729 uint8_t *sig __unused, 730 size_t *sig_len __unused) 731 { 732 return TEE_ERROR_NOT_IMPLEMENTED; 733 } 734 735 TEE_Result crypto_acipher_sm2_dsa_verify(uint32_t algo __unused, 736 struct ecc_public_key *key __unused, 737 const uint8_t *msg __unused, 738 size_t msg_len __unused, 739 const uint8_t *sig __unused, 740 size_t sig_len __unused) 741 { 742 return TEE_ERROR_NOT_IMPLEMENTED; 743 } 744 #endif /* !CFG_CRYPTO_SM2_DSA */ 745 #if !defined(CFG_CRYPTO_SM2_KEP) 746 TEE_Result crypto_acipher_sm2_kep_derive(struct ecc_keypair *my_key __unused, 747 struct ecc_keypair *my_eph_key 748 __unused, 749 struct ecc_public_key *peer_key 750 __unused, 751 struct ecc_public_key *peer_eph_key 752 __unused, 753 struct sm2_kep_parms *p __unused) 754 { 755 return TEE_ERROR_NOT_IMPLEMENTED; 756 } 757 #endif 758