1/* 2 * Copyright (c) 2022-2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit CryptoArchitectureKit 19 */ 20import type { AsyncCallback, Callback } from './@ohos.base'; 21 22/** 23 * Provides a set of encryption and decryption algorithm library framework, shields the underlying differences, 24 * encapsulate the relevant algorithm library, and provides a unified functional interface upward. 25 * 26 * @namespace cryptoFramework 27 * @syscap SystemCapability.Security.CryptoFramework 28 * @since 9 29 */ 30/** 31 * Provides a set of encryption and decryption algorithm library framework, shields the underlying differences, 32 * encapsulate the relevant algorithm library, and provides a unified functional interface upward. 33 * 34 * @namespace cryptoFramework 35 * @syscap SystemCapability.Security.CryptoFramework 36 * @crossplatform 37 * @atomicservice 38 * @since arkts {'1.1':'11','1.2':'20'} 39 * @arkts 1.1&1.2 40 */ 41declare namespace cryptoFramework { 42 /** 43 * Enum for result code. 44 * 45 * @enum { number } 46 * @syscap SystemCapability.Security.CryptoFramework 47 * @since 9 48 */ 49 /** 50 * Enum for result code. 51 * 52 * @enum { number } 53 * @syscap SystemCapability.Security.CryptoFramework 54 * @crossplatform 55 * @atomicservice 56 * @since 11 57 */ 58 enum Result { 59 /** 60 * Indicates that input parameters is invalid. 61 * 62 * @syscap SystemCapability.Security.CryptoFramework 63 * @since 9 64 */ 65 /** 66 * Indicates that input parameters is invalid. 67 * 68 * @syscap SystemCapability.Security.CryptoFramework 69 * @crossplatform 70 * @atomicservice 71 * @since 11 72 */ 73 INVALID_PARAMS = 401, 74 75 /** 76 * Indicates that function or algorithm is not supported. 77 * 78 * @syscap SystemCapability.Security.CryptoFramework 79 * @since 9 80 */ 81 /** 82 * Indicates that function or algorithm is not supported. 83 * 84 * @syscap SystemCapability.Security.CryptoFramework 85 * @crossplatform 86 * @since 11 87 */ 88 /** 89 * Indicates that function or algorithm is not supported. 90 * 91 * @syscap SystemCapability.Security.CryptoFramework 92 * @crossplatform 93 * @atomicservice 94 * @since 12 95 */ 96 NOT_SUPPORT = 801, 97 98 /** 99 * Indicates the memory operation failed. 100 * 101 * @syscap SystemCapability.Security.CryptoFramework 102 * @since 9 103 */ 104 /** 105 * Indicates the memory operation failed. 106 * 107 * @syscap SystemCapability.Security.CryptoFramework 108 * @crossplatform 109 * @atomicservice 110 * @since 11 111 */ 112 ERR_OUT_OF_MEMORY = 17620001, 113 114 /** 115 * Indicates that failed to convert parameters between arkts and c. 116 * 117 * @syscap SystemCapability.Security.CryptoFramework 118 * @since 9 119 */ 120 /** 121 * Indicates that failed to convert parameters between arkts and c. 122 * 123 * @syscap SystemCapability.Security.CryptoFramework 124 * @crossplatform 125 * @since 11 126 */ 127 /** 128 * Indicates that failed to convert parameters between arkts and c. 129 * 130 * @syscap SystemCapability.Security.CryptoFramework 131 * @crossplatform 132 * @atomicservice 133 * @since 12 134 */ 135 ERR_RUNTIME_ERROR = 17620002, 136 137 /** 138 * Indicates that parameter check failed. 139 * 140 * @syscap SystemCapability.Security.CryptoFramework 141 * @crossplatform 142 * @atomicservice 143 * @since 20 144 */ 145 ERR_PARAMETER_CHECK_FAILED = 17620003, 146 147 /** 148 * Indicates that crypto operation error. 149 * 150 * @syscap SystemCapability.Security.CryptoFramework 151 * @since 9 152 */ 153 /** 154 * Indicates that crypto operation error. 155 * 156 * @syscap SystemCapability.Security.CryptoFramework 157 * @crossplatform 158 * @atomicservice 159 * @since 11 160 */ 161 ERR_CRYPTO_OPERATION = 17630001 162 } 163 164 /** 165 * Provides the data blob type. 166 * 167 * @typedef DataBlob 168 * @syscap SystemCapability.Security.CryptoFramework 169 * @since 9 170 */ 171 /** 172 * Defines a buffer array of the Binary Large Object (BLOB) type. 173 * 174 * @typedef DataBlob 175 * @syscap SystemCapability.Security.CryptoFramework 176 * @crossplatform 177 * @atomicservice 178 * @since arkts {'1.1':'11','1.2':'20'} 179 * @arkts 1.1&1.2 180 */ 181 interface DataBlob { 182 /** 183 * Indicates the content of data blob. 184 * 185 * @type { Uint8Array } 186 * @syscap SystemCapability.Security.CryptoFramework 187 * @since 9 188 */ 189 /** 190 * Indicates the content of data blob. 191 * 192 * @type { Uint8Array } 193 * @syscap SystemCapability.Security.CryptoFramework 194 * @crossplatform 195 * @atomicservice 196 * @since arkts {'1.1':'11','1.2':'20'} 197 * @arkts 1.1&1.2 198 */ 199 data: Uint8Array; 200 } 201 202 /** 203 * Provides the ParamsSpec type, including the algorithm name. 204 * 205 * @typedef ParamsSpec 206 * @syscap SystemCapability.Security.CryptoFramework 207 * @since 9 208 */ 209 /** 210 * Provides the ParamsSpec type, including the algorithm name. 211 * 212 * @typedef ParamsSpec 213 * @syscap SystemCapability.Security.CryptoFramework 214 * @crossplatform 215 * @since 11 216 */ 217 /** 218 * Encapsulates the parameters used for encryption or decryption.You need to construct its child class object and 219 * pass it to init for symmetric encryption or decryption. 220 * 221 * @typedef ParamsSpec 222 * @syscap SystemCapability.Security.CryptoFramework.Cipher 223 * @crossplatform 224 * @atomicservice 225 * @since 12 226 */ 227 interface ParamsSpec { 228 /** 229 * Indicates the algorithm name. Should be set before initialization of a cipher object. 230 * 231 * @type { string } 232 * @syscap SystemCapability.Security.CryptoFramework 233 * @since 9 234 */ 235 /** 236 * Indicates the algorithm name. Should be set before initialization of a cipher object. 237 * 238 * @type { string } 239 * @syscap SystemCapability.Security.CryptoFramework 240 * @crossplatform 241 * @since 11 242 */ 243 /** 244 * Indicates the algorithm name. Should be set before initialization of a cipher object. 245 * 246 * @type { string } 247 * @syscap SystemCapability.Security.CryptoFramework.Cipher 248 * @crossplatform 249 * @atomicservice 250 * @since 12 251 */ 252 algName: string; 253 } 254 255 /** 256 * Provides the IvParamsSpec type, including the parameter iv. 257 * 258 * @typedef IvParamsSpec 259 * @extends ParamsSpec 260 * @syscap SystemCapability.Security.CryptoFramework 261 * @since 9 262 */ 263 /** 264 * Provides the IvParamsSpec type, including the parameter iv. 265 * 266 * @typedef IvParamsSpec 267 * @extends ParamsSpec 268 * @syscap SystemCapability.Security.CryptoFramework 269 * @crossplatform 270 * @since 11 271 */ 272 /** 273 * Defines the child class of ParamsSpec. It is a parameter of init for symmetric encryption or decryption. 274 * IvParamsSpec applies to the cipher modes such as CBC, CTR, OFB, and CFB, which use only the IV. 275 * 276 * @typedef IvParamsSpec 277 * @extends ParamsSpec 278 * @syscap SystemCapability.Security.CryptoFramework.Cipher 279 * @crossplatform 280 * @atomicservice 281 * @since 12 282 */ 283 interface IvParamsSpec extends ParamsSpec { 284 /** 285 * Indicates the algorithm parameters such as iv. 286 * 287 * @type { DataBlob } 288 * @syscap SystemCapability.Security.CryptoFramework 289 * @since 9 290 */ 291 /** 292 * Indicates the algorithm parameters such as iv. 293 * 294 * @type { DataBlob } 295 * @syscap SystemCapability.Security.CryptoFramework 296 * @crossplatform 297 * @since 11 298 */ 299 /** 300 * IV for encryption or decryption. 301 * Options: 302 * - AES CBC, CTR, OFB, or CFB mode: 16-byte IV 303 * - 3DES CBC, OFB, or CFB mode: 8-byte IV 304 * - SM4 CBC, CTR, OFB, or CFB mode: 16-byte IV 305 * 306 * @type { DataBlob } 307 * @syscap SystemCapability.Security.CryptoFramework.Cipher 308 * @crossplatform 309 * @atomicservice 310 * @since 12 311 */ 312 iv: DataBlob; 313 } 314 315 /** 316 * Provides the GcmParamsSpec type, including the parameter iv, aad and authTag. 317 * 318 * @typedef GcmParamsSpec 319 * @extends ParamsSpec 320 * @syscap SystemCapability.Security.CryptoFramework 321 * @since 9 322 */ 323 /** 324 * Provides the GcmParamsSpec type, including the parameter iv, aad and authTag. 325 * 326 * @typedef GcmParamsSpec 327 * @extends ParamsSpec 328 * @syscap SystemCapability.Security.CryptoFramework 329 * @crossplatform 330 * @since 11 331 */ 332 /** 333 * Provides the GcmParamsSpec type, including the parameter iv, aad and authTag. 334 * 335 * @typedef GcmParamsSpec 336 * @extends ParamsSpec 337 * @syscap SystemCapability.Security.CryptoFramework.Cipher 338 * @crossplatform 339 * @atomicservice 340 * @since 12 341 */ 342 interface GcmParamsSpec extends ParamsSpec { 343 /** 344 * Indicates the GCM algorithm parameters such as iv. 345 * 346 * @type { DataBlob } 347 * @syscap SystemCapability.Security.CryptoFramework 348 * @since 9 349 */ 350 /** 351 * Indicates the GCM algorithm parameters such as iv. 352 * 353 * @type { DataBlob } 354 * @syscap SystemCapability.Security.CryptoFramework 355 * @crossplatform 356 * @since 11 357 */ 358 /** 359 * Indicates the GCM algorithm parameters such as iv. 360 * 361 * @type { DataBlob } 362 * @syscap SystemCapability.Security.CryptoFramework.Cipher 363 * @crossplatform 364 * @atomicservice 365 * @since 12 366 */ 367 iv: DataBlob; 368 369 /** 370 * Indicates the additional Authenticated Data in GCM mode. 371 * 372 * @type { DataBlob } 373 * @syscap SystemCapability.Security.CryptoFramework 374 * @since 9 375 */ 376 /** 377 * Indicates the additional Authenticated Data in GCM mode. 378 * 379 * @type { DataBlob } 380 * @syscap SystemCapability.Security.CryptoFramework 381 * @crossplatform 382 * @since 11 383 */ 384 /** 385 * Indicates the additional Authenticated Data in GCM mode. 386 * 387 * @type { DataBlob } 388 * @syscap SystemCapability.Security.CryptoFramework.Cipher 389 * @crossplatform 390 * @atomicservice 391 * @since 12 392 */ 393 aad: DataBlob; 394 395 /** 396 * Indicates the output tag from the encryption operation. The tag is used for integrity check. 397 * 398 * @type { DataBlob } 399 * @syscap SystemCapability.Security.CryptoFramework 400 * @since 9 401 */ 402 /** 403 * Indicates the output tag from the encryption operation. The tag is used for integrity check. 404 * 405 * @type { DataBlob } 406 * @syscap SystemCapability.Security.CryptoFramework 407 * @crossplatform 408 * @since 11 409 */ 410 /** 411 * Indicates the output tag from the encryption operation. The tag is used for integrity check. 412 * 413 * @type { DataBlob } 414 * @syscap SystemCapability.Security.CryptoFramework.Cipher 415 * @crossplatform 416 * @atomicservice 417 * @since 12 418 */ 419 authTag: DataBlob; 420 } 421 422 /** 423 * Provides the CcmParamsSpec type, including the parameter iv, aad and authTag. 424 * 425 * @typedef CcmParamsSpec 426 * @extends ParamsSpec 427 * @syscap SystemCapability.Security.CryptoFramework 428 * @since 9 429 */ 430 /** 431 * Provides the CcmParamsSpec type, including the parameter iv, aad and authTag. 432 * 433 * @typedef CcmParamsSpec 434 * @extends ParamsSpec 435 * @syscap SystemCapability.Security.CryptoFramework 436 * @crossplatform 437 * @since 11 438 */ 439 /** 440 * Provides the CcmParamsSpec type, including the parameter iv, aad and authTag. 441 * 442 * @typedef CcmParamsSpec 443 * @extends ParamsSpec 444 * @syscap SystemCapability.Security.CryptoFramework.Cipher 445 * @crossplatform 446 * @atomicservice 447 * @since 12 448 */ 449 interface CcmParamsSpec extends ParamsSpec { 450 /** 451 * Indicates the GCM algorithm parameters such as IV. 452 * 453 * @type { DataBlob } 454 * @syscap SystemCapability.Security.CryptoFramework 455 * @since 9 456 */ 457 /** 458 * Indicates the GCM algorithm parameters such as IV. 459 * 460 * @type { DataBlob } 461 * @syscap SystemCapability.Security.CryptoFramework 462 * @crossplatform 463 * @since 11 464 */ 465 /** 466 * Indicates the GCM algorithm parameters such as IV. 467 * 468 * @type { DataBlob } 469 * @syscap SystemCapability.Security.CryptoFramework.Cipher 470 * @crossplatform 471 * @atomicservice 472 * @since 12 473 */ 474 iv: DataBlob; 475 476 /** 477 * Indicates the Additional Authenticated Data in CCM mode. 478 * 479 * @type { DataBlob } 480 * @syscap SystemCapability.Security.CryptoFramework 481 * @since 9 482 */ 483 /** 484 * Indicates the Additional Authenticated Data in CCM mode. 485 * 486 * @type { DataBlob } 487 * @syscap SystemCapability.Security.CryptoFramework 488 * @crossplatform 489 * @since 11 490 */ 491 /** 492 * Indicates the Additional Authenticated Data in CCM mode. 493 * 494 * @type { DataBlob } 495 * @syscap SystemCapability.Security.CryptoFramework.Cipher 496 * @crossplatform 497 * @atomicservice 498 * @since 12 499 */ 500 aad: DataBlob; 501 502 /** 503 * Indicates the output tag from the encryption operation. The tag is used for integrity check. 504 * 505 * @type { DataBlob } 506 * @syscap SystemCapability.Security.CryptoFramework 507 * @since 9 508 */ 509 /** 510 * Indicates the output tag from the encryption operation. The tag is used for integrity check. 511 * 512 * @type { DataBlob } 513 * @syscap SystemCapability.Security.CryptoFramework 514 * @crossplatform 515 * @since 11 516 */ 517 /** 518 * Indicates the output tag from the encryption operation. The tag is used for integrity check. 519 * 520 * @type { DataBlob } 521 * @syscap SystemCapability.Security.CryptoFramework.Cipher 522 * @crossplatform 523 * @atomicservice 524 * @since 12 525 */ 526 authTag: DataBlob; 527 } 528 529 /** 530 * Enum for obtain the crypto operation. 531 * 532 * @enum { number } 533 * @syscap SystemCapability.Security.CryptoFramework 534 * @since 9 535 */ 536 /** 537 * Enum for obtain the crypto operation. 538 * 539 * @enum { number } 540 * @syscap SystemCapability.Security.CryptoFramework 541 * @crossplatform 542 * @since 11 543 */ 544 /** 545 * Enumerates the cryptographic operations. 546 * 547 * @enum { number } 548 * @syscap SystemCapability.Security.CryptoFramework.Cipher 549 * @crossplatform 550 * @atomicservice 551 * @since 12 552 */ 553 enum CryptoMode { 554 /** 555 * The value of encryption operation for AES, 3DES and RSA. 556 * 557 * @syscap SystemCapability.Security.CryptoFramework 558 * @since 9 559 */ 560 /** 561 * The value of encryption operation for AES, 3DES and RSA. 562 * 563 * @syscap SystemCapability.Security.CryptoFramework 564 * @crossplatform 565 * @since 11 566 */ 567 /** 568 * The value of encryption operation for AES, 3DES and RSA. 569 * 570 * @syscap SystemCapability.Security.CryptoFramework.Cipher 571 * @crossplatform 572 * @atomicservice 573 * @since 12 574 */ 575 ENCRYPT_MODE = 0, 576 577 /** 578 * The value of decryption operation for AES, 3DES and RSA. 579 * 580 * @syscap SystemCapability.Security.CryptoFramework 581 * @since 9 582 */ 583 /** 584 * The value of decryption operation for AES, 3DES and RSA. 585 * 586 * @syscap SystemCapability.Security.CryptoFramework 587 * @crossplatform 588 * @since 11 589 */ 590 /** 591 * The value of decryption operation for AES, 3DES and RSA. 592 * 593 * @syscap SystemCapability.Security.CryptoFramework.Cipher 594 * @crossplatform 595 * @atomicservice 596 * @since 12 597 */ 598 DECRYPT_MODE = 1 599 } 600 601 /** 602 * Represents the RSA private key encoding parameters. You can use it to generate an encoded private key string with the specified algorithm and password. 603 * 604 * @typedef KeyEncodingConfig 605 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 606 * @crossplatform 607 * @atomicservice 608 * @since 18 609 */ 610 interface KeyEncodingConfig { 611 /** 612 * The password to encrypt the private key. 613 * 614 * @type { string } 615 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 616 * @crossplatform 617 * @atomicservice 618 * @since 18 619 */ 620 password: string; 621 622 /** 623 * The symmetric cipher name to encrypt the private key, such as "AES-256-CBC". 624 * 625 * @type { string } 626 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 627 * @crossplatform 628 * @atomicservice 629 * @since 18 630 */ 631 cipherName: string; 632 } 633 634 635 /** 636 * Provides the Key type, which is the common parent class of keys. 637 * 638 * @typedef Key 639 * @syscap SystemCapability.Security.CryptoFramework 640 * @since 9 641 */ 642 /** 643 * Provides the Key type, which is the common parent class of keys. 644 * 645 * @typedef Key 646 * @syscap SystemCapability.Security.CryptoFramework 647 * @crossplatform 648 * @since 11 649 */ 650 /** 651 * Provides the Key type, which is the common parent class of keys. 652 * Before performing cryptographic operations, you need to construct a child class object of Key and pass it to init of the Cipher instance. 653 * 654 * @typedef Key 655 * @syscap SystemCapability.Security.CryptoFramework.Key 656 * @crossplatform 657 * @atomicservice 658 * @since arkts {'1.1':'12','1.2':'20'} 659 * @arkts 1.1&1.2 660 */ 661 interface Key { 662 /** 663 * Encode the key object to binary data. 664 * 665 * @returns { DataBlob } the binary data of the key object. 666 * @throws { BusinessError } 801 - this operation is not supported. 667 * @throws { BusinessError } 17620001 - memory operation failed. 668 * @throws { BusinessError } 17630001 - crypto operation error. 669 * @syscap SystemCapability.Security.CryptoFramework 670 * @since 9 671 */ 672 /** 673 * Encode the key object to binary data. 674 * 675 * @returns { DataBlob } the binary data of the key object. 676 * @throws { BusinessError } 801 - this operation is not supported. 677 * @throws { BusinessError } 17620001 - memory operation failed. 678 * @throws { BusinessError } 17630001 - crypto operation error. 679 * @syscap SystemCapability.Security.CryptoFramework 680 * @crossplatform 681 * @since 11 682 */ 683 /** 684 * Encode the key object to binary data. 685 * The key can be a symmetric key, public key, or private key. 686 * The public key must be in DER encoding format and comply with the ASN.1 syntax and X.509 specifications. 687 * The private key must be in DER encoding format and comply with the ASN.1 syntax and PKCS#8 specifications. 688 * 689 * @returns { DataBlob } the binary data of the key object. 690 * @throws { BusinessError } 801 - this operation is not supported. 691 * @throws { BusinessError } 17620001 - memory operation failed. 692 * @throws { BusinessError } 17630001 - crypto operation error. 693 * @syscap SystemCapability.Security.CryptoFramework.Key 694 * @crossplatform 695 * @atomicservice 696 * @since 12 697 */ 698 getEncoded(): DataBlob; 699 700 /** 701 * Indicates the format of the key object. 702 * 703 * @type { string } 704 * @readonly 705 * @syscap SystemCapability.Security.CryptoFramework 706 * @since 9 707 */ 708 /** 709 * Indicates the format of the key object. 710 * 711 * @type { string } 712 * @readonly 713 * @syscap SystemCapability.Security.CryptoFramework 714 * @crossplatform 715 * @since 11 716 */ 717 /** 718 * Indicates the format of the key object. 719 * 720 * @type { string } 721 * @readonly 722 * @syscap SystemCapability.Security.CryptoFramework.Key 723 * @crossplatform 724 * @atomicservice 725 * @since 12 726 */ 727 readonly format: string; 728 729 /** 730 * Indicates the algorithm name of the key object. 731 * 732 * @type { string } 733 * @readonly 734 * @syscap SystemCapability.Security.CryptoFramework 735 * @since 9 736 */ 737 /** 738 * Indicates the algorithm name of the key object. 739 * 740 * @type { string } 741 * @readonly 742 * @syscap SystemCapability.Security.CryptoFramework 743 * @crossplatform 744 * @since 11 745 */ 746 /** 747 * Indicates the algorithm name of the key object. This parameter contains the key length if the key is a symmetric key. 748 * 749 * @type { string } 750 * @readonly 751 * @syscap SystemCapability.Security.CryptoFramework.Key 752 * @crossplatform 753 * @atomicservice 754 * @since 12 755 */ 756 readonly algName: string; 757 } 758 759 /** 760 * Provides the SymKey type, which is used for symmetric cryptography. 761 * 762 * @typedef SymKey 763 * @extends Key 764 * @syscap SystemCapability.Security.CryptoFramework 765 * @since 9 766 */ 767 /** 768 * Provides the SymKey type, which is used for symmetric cryptography. 769 * 770 * @typedef SymKey 771 * @extends Key 772 * @syscap SystemCapability.Security.CryptoFramework 773 * @crossplatform 774 * @since 11 775 */ 776 /** 777 * Provides APIs for symmetric key operations. 778 * Its objects need to be passed to init of the Cipher instance in symmetric encryption and decryption. 779 * 780 * @typedef SymKey 781 * @extends Key 782 * @syscap SystemCapability.Security.CryptoFramework.Key.SymKey 783 * @crossplatform 784 * @atomicservice 785 * @since arkts {'1.1':'12','1.2':'20'} 786 * @arkts 1.1&1.2 787 */ 788 interface SymKey extends Key { 789 /** 790 * Reset the key data to zero in the memory. 791 * 792 * @syscap SystemCapability.Security.CryptoFramework 793 * @since 9 794 */ 795 /** 796 * Reset the key data to zero in the memory. 797 * 798 * @syscap SystemCapability.Security.CryptoFramework 799 * @crossplatform 800 * @since 11 801 */ 802 /** 803 * Clears the keys in the memory. This API returns the result synchronously. 804 * You are advised to use this API when symmetric key instances are no longer used. 805 * 806 * @syscap SystemCapability.Security.CryptoFramework.Key.SymKey 807 * @crossplatform 808 * @atomicservice 809 * @since 12 810 */ 811 clearMem(): void; 812 } 813 814 /** 815 * Provides the private key type. 816 * 817 * @typedef PriKey 818 * @extends Key 819 * @syscap SystemCapability.Security.CryptoFramework 820 * @since 9 821 */ 822 /** 823 * Provides the private key type. 824 * 825 * @typedef PriKey 826 * @extends Key 827 * @syscap SystemCapability.Security.CryptoFramework 828 * @crossplatform 829 * @since 11 830 */ 831 /** 832 * Provides the private key type. It needs to be passed in during asymmetric encryption and decryption, signing, and key agreement. 833 * 834 * @typedef PriKey 835 * @extends Key 836 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 837 * @crossplatform 838 * @atomicservice 839 * @since 12 840 */ 841 interface PriKey extends Key { 842 /** 843 * Clear memory of private key. 844 * 845 * @syscap SystemCapability.Security.CryptoFramework 846 * @since 9 847 */ 848 /** 849 * Clear memory of private key. 850 * 851 * @syscap SystemCapability.Security.CryptoFramework 852 * @crossplatform 853 * @since 11 854 */ 855 /** 856 * Clear memory of private key. 857 * 858 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 859 * @crossplatform 860 * @atomicservice 861 * @since 12 862 */ 863 clearMem(): void; 864 865 /** 866 * Get the specified parameter of the private key. 867 * 868 * @param { AsyKeySpecItem } itemType - indicates the specified parameters type. 869 * @returns { bigint | string | number } the specified parameters value. 870 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 871 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 872 * @throws { BusinessError } 801 - this operation is not supported. 873 * @throws { BusinessError } 17620001 - memory operation failed. 874 * @throws { BusinessError } 17630001 - crypto operation error. 875 * @syscap SystemCapability.Security.CryptoFramework 876 * @since 10 877 */ 878 /** 879 * Get the specified parameter of the private key. 880 * 881 * @param { AsyKeySpecItem } itemType - indicates the specified parameters type. 882 * @returns { bigint | string | number } the specified parameters value. 883 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 884 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 885 * @throws { BusinessError } 801 - this operation is not supported. 886 * @throws { BusinessError } 17620001 - memory operation failed. 887 * @throws { BusinessError } 17630001 - crypto operation error. 888 * @syscap SystemCapability.Security.CryptoFramework 889 * @crossplatform 890 * @since 11 891 */ 892 /** 893 * Get the specified parameter of the private key. 894 * 895 * @param { AsyKeySpecItem } itemType - indicates the specified parameters type. 896 * @returns { bigint | string | number } the specified parameters value. 897 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 898 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 899 * @throws { BusinessError } 801 - this operation is not supported. 900 * @throws { BusinessError } 17620001 - memory operation failed. 901 * @throws { BusinessError } 17630001 - crypto operation error. 902 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 903 * @crossplatform 904 * @atomicservice 905 * @since 12 906 */ 907 getAsyKeySpec(itemType: AsyKeySpecItem): bigint | string | number; 908 909 /** 910 * Encode the private key object to binary data in DER format. 911 * 912 * @param { string } format - indicates the encoding format. 913 * @returns { DataBlob } the binary data of the key object in DER format. 914 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 915 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 916 * @throws { BusinessError } 17620001 - memory operation failed. 917 * @throws { BusinessError } 17630001 - crypto operation error. 918 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 919 * @crossplatform 920 * @atomicservice 921 * @since 12 922 */ 923 getEncodedDer(format: string): DataBlob; 924 925 /** 926 * Encode the private key object to string in PEM format. 927 * The key can be an RSA public or private key. The private key must comply with PKCS8 or PKCS1 specifications and PEM encoding format. 928 * 929 * @param { string } format - indicates the encoding format. 930 * @returns { string } the string of the key object in PEM format. 931 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 932 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 933 * @throws { BusinessError } 17620001 - memory operation failed. 934 * @throws { BusinessError } 17630001 - crypto operation error. 935 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 936 * @crossplatform 937 * @atomicservice 938 * @since 12 939 */ 940 getEncodedPem(format: string): string; 941 942 /** 943 * Encode the private key object to string in PEM format. 944 * The key can be an RSA public or private key. The private key must comply with PKCS8 or PKCS1 specifications and PEM encoding format. 945 * 946 * @param { string } format - indicates the encoding format. 947 * @param { KeyEncodingConfig } config - indicates the encoding configuration. 948 * @returns { string } the string of the key object in PEM format. 949 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 950 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 951 * @throws { BusinessError } 801 - this operation is not supported. 952 * @throws { BusinessError } 17620001 - memory operation failed. 953 * @throws { BusinessError } 17630001 - crypto operation error. 954 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 955 * @crossplatform 956 * @atomicservice 957 * @since 18 958 */ 959 getEncodedPem(format: string, config: KeyEncodingConfig): string; 960 } 961 962 /** 963 * Provides the public key interface for asymmetric keys. 964 * 965 * @typedef PubKey 966 * @extends Key 967 * @syscap SystemCapability.Security.CryptoFramework 968 * @since 9 969 */ 970 /** 971 * Provides the public key interface for asymmetric keys. 972 * 973 * @typedef PubKey 974 * @extends Key 975 * @syscap SystemCapability.Security.CryptoFramework 976 * @crossplatform 977 * @since 11 978 */ 979 /** 980 * Provides the public key interface for asymmetric keys. 981 * 982 * @typedef PubKey 983 * @extends Key 984 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 985 * @crossplatform 986 * @atomicservice 987 * @since 12 988 */ 989 interface PubKey extends Key { 990 /** 991 * Get the specified parameter of the public key. 992 * 993 * @param { AsyKeySpecItem } itemType - indicates the specified parameters type. 994 * @returns { bigint | string | number } the specified parameters value. 995 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 996 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 997 * @throws { BusinessError } 17620001 - memory operation failed. 998 * @throws { BusinessError } 17630001 - crypto operation error. 999 * @syscap SystemCapability.Security.CryptoFramework 1000 * @since 10 1001 */ 1002 /** 1003 * Get the specified parameter of the public key. 1004 * 1005 * @param { AsyKeySpecItem } itemType - indicates the specified parameters type. 1006 * @returns { bigint | string | number } the specified parameters value. 1007 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1008 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1009 * @throws { BusinessError } 17620001 - memory operation failed. 1010 * @throws { BusinessError } 17630001 - crypto operation error. 1011 * @syscap SystemCapability.Security.CryptoFramework 1012 * @crossplatform 1013 * @since 11 1014 */ 1015 /** 1016 * Get the specified parameter of the public key. 1017 * 1018 * @param { AsyKeySpecItem } itemType - indicates the specified parameters type. 1019 * @returns { bigint | string | number } the specified parameters value. 1020 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1021 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1022 * @throws { BusinessError } 801 - this operation is not supported. 1023 * @throws { BusinessError } 17620001 - memory operation failed. 1024 * @throws { BusinessError } 17630001 - crypto operation error. 1025 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 1026 * @crossplatform 1027 * @atomicservice 1028 * @since 12 1029 */ 1030 getAsyKeySpec(itemType: AsyKeySpecItem): bigint | string | number; 1031 1032 /** 1033 * Encode the public key object to binary data in DER format. 1034 * Currently, only compressed and uncompressed ECC public key data can be obtained. 1035 * 1036 * @param { string } format - indicates the encoding format. 1037 * @returns { DataBlob } the binary data of the key object in DER format. 1038 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1039 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1040 * @throws { BusinessError } 17620001 - memory operation failed. 1041 * @throws { BusinessError } 17630001 - crypto operation error. 1042 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 1043 * @crossplatform 1044 * @atomicservice 1045 * @since 12 1046 */ 1047 getEncodedDer(format: string): DataBlob; 1048 1049 /** 1050 * Encode the public key object to string in PEM format. 1051 * The public key must comply with the X.509 specifications, PKCS1 specifications, and PEM encoding format. 1052 * 1053 * @param { string } format - indicates the encoding format. 1054 * @returns { string } the string of the key object in PEM format. 1055 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1056 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1057 * @throws { BusinessError } 17620001 - memory operation failed. 1058 * @throws { BusinessError } 17630001 - crypto operation error. 1059 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 1060 * @crossplatform 1061 * @atomicservice 1062 * @since 12 1063 */ 1064 getEncodedPem(format: string): string; 1065 } 1066 1067 /** 1068 * Provides the keypair interface for asymmetric keys. A keyPair object contains both private key and public key. 1069 * 1070 * @typedef KeyPair 1071 * @syscap SystemCapability.Security.CryptoFramework 1072 * @since 9 1073 */ 1074 /** 1075 * Provides the keypair interface for asymmetric keys. A keyPair object contains both private key and public key. 1076 * 1077 * @typedef KeyPair 1078 * @syscap SystemCapability.Security.CryptoFramework 1079 * @crossplatform 1080 * @since 11 1081 */ 1082 /** 1083 * Provides the keypair interface for asymmetric keys. A keyPair object contains both private key and public key. 1084 * 1085 * @typedef KeyPair 1086 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 1087 * @crossplatform 1088 * @atomicservice 1089 * @since 12 1090 */ 1091 interface KeyPair { 1092 /** 1093 * KeyPair's private key. 1094 * 1095 * @type { PriKey } 1096 * @readonly 1097 * @syscap SystemCapability.Security.CryptoFramework 1098 * @since 9 1099 */ 1100 /** 1101 * KeyPair's private key. 1102 * 1103 * @type { PriKey } 1104 * @readonly 1105 * @syscap SystemCapability.Security.CryptoFramework 1106 * @crossplatform 1107 * @since 11 1108 */ 1109 /** 1110 * KeyPair's private key. 1111 * 1112 * @type { PriKey } 1113 * @readonly 1114 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 1115 * @crossplatform 1116 * @atomicservice 1117 * @since 12 1118 */ 1119 readonly priKey: PriKey; 1120 1121 /** 1122 * KeyPair's public key. 1123 * 1124 * @type { PubKey } 1125 * @readonly 1126 * @syscap SystemCapability.Security.CryptoFramework 1127 * @since 9 1128 */ 1129 /** 1130 * KeyPair's public key. 1131 * 1132 * @type { PubKey } 1133 * @readonly 1134 * @syscap SystemCapability.Security.CryptoFramework 1135 * @crossplatform 1136 * @since 11 1137 */ 1138 /** 1139 * KeyPair's public key. 1140 * 1141 * @type { PubKey } 1142 * @readonly 1143 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 1144 * @crossplatform 1145 * @atomicservice 1146 * @since 12 1147 */ 1148 readonly pubKey: PubKey; 1149 } 1150 1151 /** 1152 * Provides the random interface. 1153 * 1154 * @typedef Random 1155 * @syscap SystemCapability.Security.CryptoFramework 1156 * @since 9 1157 */ 1158 /** 1159 * Provides the random interface. 1160 * 1161 * @typedef Random 1162 * @syscap SystemCapability.Security.CryptoFramework 1163 * @crossplatform 1164 * @atomicservice 1165 * @since 11 1166 */ 1167 /** 1168 * Provides APIs for computing random numbers and setting seeds. 1169 * 1170 * @typedef Random 1171 * @syscap SystemCapability.Security.CryptoFramework.Rand 1172 * @crossplatform 1173 * @atomicservice 1174 * @since 12 1175 */ 1176 interface Random { 1177 /** 1178 * Generate random DataBlob by given length. 1179 * 1180 * @param { number } len - indicates the length of random DataBlob. 1181 * @param { AsyncCallback<DataBlob> } callback - the callback used to return random DataBlob. 1182 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1183 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1184 * @throws { BusinessError } 17620001 - memory operation failed. 1185 * @throws { BusinessError } 17630001 - crypto operation error. 1186 * @syscap SystemCapability.Security.CryptoFramework 1187 * @since 9 1188 */ 1189 /** 1190 * Generate random DataBlob by given length. 1191 * 1192 * @param { number } len - indicates the length of random DataBlob. 1193 * @param { AsyncCallback<DataBlob> } callback - the callback used to return random DataBlob. 1194 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1195 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1196 * @throws { BusinessError } 17620001 - memory operation failed. 1197 * @throws { BusinessError } 17630001 - crypto operation error. 1198 * @syscap SystemCapability.Security.CryptoFramework 1199 * @crossplatform 1200 * @atomicservice 1201 * @since 11 1202 */ 1203 /** 1204 * Generate random DataBlob by given length. 1205 * 1206 * @param { number } len - indicates the length of random DataBlob. 1207 * @param { AsyncCallback<DataBlob> } callback - the callback used to return random DataBlob. 1208 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1209 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1210 * @throws { BusinessError } 17620001 - memory operation failed. 1211 * @throws { BusinessError } 17630001 - crypto operation error. 1212 * @syscap SystemCapability.Security.CryptoFramework.Rand 1213 * @crossplatform 1214 * @atomicservice 1215 * @since 12 1216 */ 1217 generateRandom(len: number, callback: AsyncCallback<DataBlob>): void; 1218 1219 /** 1220 * Generate random DataBlob by given length. 1221 * 1222 * @param { number } len - indicates the length of random DataBlob. 1223 * @returns { Promise<DataBlob> } the promise used to return the generated random blob. 1224 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1225 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1226 * @throws { BusinessError } 17620001 - memory operation failed. 1227 * @throws { BusinessError } 17630001 - crypto operation error. 1228 * @syscap SystemCapability.Security.CryptoFramework 1229 * @since 9 1230 */ 1231 /** 1232 * Generate random DataBlob by given length. 1233 * 1234 * @param { number } len - indicates the length of random DataBlob. 1235 * @returns { Promise<DataBlob> } the promise used to return the generated random blob. 1236 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1237 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1238 * @throws { BusinessError } 17620001 - memory operation failed. 1239 * @throws { BusinessError } 17630001 - crypto operation error. 1240 * @syscap SystemCapability.Security.CryptoFramework 1241 * @crossplatform 1242 * @atomicservice 1243 * @since 11 1244 */ 1245 /** 1246 * Generate random DataBlob by given length. 1247 * 1248 * @param { number } len - indicates the length of random DataBlob. 1249 * @returns { Promise<DataBlob> } the promise used to return the generated random blob. 1250 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1251 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1252 * @throws { BusinessError } 17620001 - memory operation failed. 1253 * @throws { BusinessError } 17630001 - crypto operation error. 1254 * @syscap SystemCapability.Security.CryptoFramework.Rand 1255 * @crossplatform 1256 * @atomicservice 1257 * @since 12 1258 */ 1259 generateRandom(len: number): Promise<DataBlob>; 1260 1261 /** 1262 * Generate random DataBlob by given length synchronously. 1263 * 1264 * @param { number } len - indicates the length of random DataBlob. 1265 * @returns { DataBlob } return the generated random blob. 1266 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1267 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1268 * @throws { BusinessError } 17620001 - memory operation failed. 1269 * @throws { BusinessError } 17630001 - crypto operation error. 1270 * @syscap SystemCapability.Security.CryptoFramework 1271 * @since 10 1272 */ 1273 /** 1274 * Generate random DataBlob by given length synchronously. 1275 * 1276 * @param { number } len - indicates the length of random DataBlob. 1277 * @returns { DataBlob } return the generated random blob. 1278 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1279 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1280 * @throws { BusinessError } 17620001 - memory operation failed. 1281 * @throws { BusinessError } 17630001 - crypto operation error. 1282 * @syscap SystemCapability.Security.CryptoFramework 1283 * @crossplatform 1284 * @atomicservice 1285 * @since 11 1286 */ 1287 /** 1288 * Generate random DataBlob by given length synchronously. 1289 * 1290 * @param { number } len - indicates the length of random DataBlob. 1291 * @returns { DataBlob } return the generated random blob. 1292 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1293 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1294 * @throws { BusinessError } 17620001 - memory operation failed. 1295 * @throws { BusinessError } 17630001 - crypto operation error. 1296 * @syscap SystemCapability.Security.CryptoFramework.Rand 1297 * @crossplatform 1298 * @atomicservice 1299 * @since 12 1300 */ 1301 generateRandomSync(len: number): DataBlob; 1302 1303 /** 1304 * Set seed by given DataBlob. 1305 * 1306 * @param { DataBlob } seed - indicates the seed DataBlob. 1307 * @throws { BusinessError } 17620001 - memory operation failed. 1308 * @syscap SystemCapability.Security.CryptoFramework 1309 * @crossplatform 1310 * @since 9 1311 */ 1312 /** 1313 * Set seed by given DataBlob. 1314 * 1315 * @param { DataBlob } seed - indicates the seed DataBlob. 1316 * @throws { BusinessError } 17620001 - memory operation failed. 1317 * @syscap SystemCapability.Security.CryptoFramework 1318 * @crossplatform 1319 * @atomicservice 1320 * @since 11 1321 */ 1322 /** 1323 * Set seed by given DataBlob. 1324 * 1325 * @param { DataBlob } seed - indicates the seed DataBlob. 1326 * @throws { BusinessError } 17620001 - memory operation failed. 1327 * @syscap SystemCapability.Security.CryptoFramework.Rand 1328 * @crossplatform 1329 * @atomicservice 1330 * @since 12 1331 */ 1332 setSeed(seed: DataBlob): void; 1333 1334 /** 1335 * Indicates the random generation algorithm name. 1336 * 1337 * @type { string } 1338 * @readonly 1339 * @syscap SystemCapability.Security.CryptoFramework 1340 * @since 10 1341 */ 1342 /** 1343 * Indicates the random generation algorithm name. 1344 * 1345 * @type { string } 1346 * @readonly 1347 * @syscap SystemCapability.Security.CryptoFramework 1348 * @crossplatform 1349 * @atomicservice 1350 * @since 11 1351 */ 1352 /** 1353 * Indicates the random generation algorithm name. Currently, only CTR_DRBG is supported. 1354 * 1355 * @type { string } 1356 * @readonly 1357 * @syscap SystemCapability.Security.CryptoFramework.Rand 1358 * @crossplatform 1359 * @atomicservice 1360 * @since 12 1361 */ 1362 readonly algName: string; 1363 } 1364 1365 /** 1366 * Create a random generator instance. 1367 * 1368 * @returns { Random } returns the created rand instance. 1369 * @throws { BusinessError } 17620001 - memory operation failed. 1370 * @syscap SystemCapability.Security.CryptoFramework 1371 * @since 9 1372 */ 1373 /** 1374 * Create a random generator instance. 1375 * 1376 * @returns { Random } returns the created rand instance. 1377 * @throws { BusinessError } 17620001 - memory operation failed. 1378 * @syscap SystemCapability.Security.CryptoFramework 1379 * @crossplatform 1380 * @atomicservice 1381 * @since 11 1382 */ 1383 /** 1384 * Create a random generator instance. 1385 * 1386 * @returns { Random } returns the created rand instance. 1387 * @throws { BusinessError } 17620001 - memory operation failed. 1388 * @syscap SystemCapability.Security.CryptoFramework.Rand 1389 * @crossplatform 1390 * @atomicservice 1391 * @since 12 1392 */ 1393 function createRandom(): Random; 1394 1395 /** 1396 * The AsyKeyGenerator provides the ability to generate or convert keyPair. 1397 * 1398 * @typedef AsyKeyGenerator 1399 * @syscap SystemCapability.Security.CryptoFramework 1400 * @since 9 1401 */ 1402 /** 1403 * The AsyKeyGenerator provides the ability to generate or convert keyPair. 1404 * 1405 * @typedef AsyKeyGenerator 1406 * @syscap SystemCapability.Security.CryptoFramework 1407 * @crossplatform 1408 * @since 11 1409 */ 1410 /** 1411 * The AsyKeyGenerator provides the ability to generate or convert keyPair. 1412 * 1413 * @typedef AsyKeyGenerator 1414 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 1415 * @crossplatform 1416 * @atomicservice 1417 * @since 12 1418 */ 1419 interface AsyKeyGenerator { 1420 /** 1421 * Used to generate asymmetric keypair. 1422 * 1423 * @param { AsyncCallback<KeyPair> } callback - the callback used to return keypair. 1424 * @throws { BusinessError } 401 - invalid parameters. Possible causes: Incorrect parameter types; 1425 * @throws { BusinessError } 17620001 - memory operation failed. 1426 * @throws { BusinessError } 17630001 - crypto operation error. 1427 * @syscap SystemCapability.Security.CryptoFramework 1428 * @since 9 1429 */ 1430 /** 1431 * Used to generate asymmetric keypair. 1432 * 1433 * @param { AsyncCallback<KeyPair> } callback - the callback used to return keypair. 1434 * @throws { BusinessError } 401 - invalid parameters. Possible causes: Incorrect parameter types; 1435 * @throws { BusinessError } 17620001 - memory operation failed. 1436 * @throws { BusinessError } 17630001 - crypto operation error. 1437 * @syscap SystemCapability.Security.CryptoFramework 1438 * @crossplatform 1439 * @since 11 1440 */ 1441 /** 1442 * Used to generate asymmetric keypair. 1443 * 1444 * @param { AsyncCallback<KeyPair> } callback - the callback used to return keypair. 1445 * @throws { BusinessError } 401 - invalid parameters. Possible causes: Incorrect parameter types; 1446 * @throws { BusinessError } 17620001 - memory operation failed. 1447 * @throws { BusinessError } 17630001 - crypto operation error. 1448 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 1449 * @crossplatform 1450 * @atomicservice 1451 * @since 12 1452 */ 1453 generateKeyPair(callback: AsyncCallback<KeyPair>): void; 1454 1455 /** 1456 * Used to generate asymmetric keypair. 1457 * 1458 * @returns { Promise<KeyPair> } the promise used to return keypair. 1459 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1460 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1461 * @throws { BusinessError } 17620001 - memory operation failed. 1462 * @throws { BusinessError } 17630001 - crypto operation error. 1463 * @syscap SystemCapability.Security.CryptoFramework 1464 * @since 9 1465 */ 1466 /** 1467 * Used to generate asymmetric keypair. 1468 * 1469 * @returns { Promise<KeyPair> } the promise used to return keypair. 1470 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1471 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1472 * @throws { BusinessError } 17620001 - memory operation failed. 1473 * @throws { BusinessError } 17630001 - crypto operation error. 1474 * @syscap SystemCapability.Security.CryptoFramework 1475 * @crossplatform 1476 * @since 11 1477 */ 1478 /** 1479 * Used to generate asymmetric keypair. 1480 * 1481 * @returns { Promise<KeyPair> } the promise used to return keypair. 1482 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1483 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1484 * @throws { BusinessError } 17620001 - memory operation failed. 1485 * @throws { BusinessError } 17630001 - crypto operation error. 1486 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 1487 * @crossplatform 1488 * @atomicservice 1489 * @since 12 1490 */ 1491 generateKeyPair(): Promise<KeyPair>; 1492 1493 /** 1494 * Used to generate asymmetric keypair. 1495 * 1496 * @returns { KeyPair } return keypair. 1497 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1498 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1499 * @throws { BusinessError } 17620001 - memory operation failed. 1500 * @throws { BusinessError } 17630001 - crypto operation error. 1501 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 1502 * @crossplatform 1503 * @atomicservice 1504 * @since 12 1505 */ 1506 generateKeyPairSync(): KeyPair; 1507 1508 /** 1509 * Used to convert asymmetric key data to keypair object. 1510 * 1511 * @param { DataBlob } pubKey - the public key data blob. 1512 * @param { DataBlob } priKey - the private key data blob. 1513 * @param { AsyncCallback<KeyPair> } callback - the callback used to return keypair. 1514 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1515 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1516 * @throws { BusinessError } 17620001 - memory operation failed. 1517 * @throws { BusinessError } 17630001 - crypto operation error. 1518 * @syscap SystemCapability.Security.CryptoFramework 1519 * @since 9 1520 */ 1521 /** 1522 * Used to convert asymmetric key data to keypair object. 1523 * 1524 * @param { DataBlob } pubKey - the public key data blob. 1525 * @param { DataBlob } priKey - the private key data blob. 1526 * @param { AsyncCallback<KeyPair> } callback - the callback used to return keypair. 1527 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1528 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1529 * @throws { BusinessError } 17620001 - memory operation failed. 1530 * @throws { BusinessError } 17630001 - crypto operation error. 1531 * @syscap SystemCapability.Security.CryptoFramework 1532 * @crossplatform 1533 * @since 11 1534 */ 1535 /** 1536 * Used to convert asymmetric key data to keypair object. 1537 * 1538 * @param { DataBlob } pubKey - the public key data blob. 1539 * @param { DataBlob } priKey - the private key data blob. 1540 * @param { AsyncCallback<KeyPair> } callback - the callback used to return keypair. 1541 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1542 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1543 * @throws { BusinessError } 17620001 - memory operation failed. 1544 * @throws { BusinessError } 17630001 - crypto operation error. 1545 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 1546 * @crossplatform 1547 * @atomicservice 1548 * @since 12 1549 */ 1550 convertKey(pubKey: DataBlob, priKey: DataBlob, callback: AsyncCallback<KeyPair>): void; 1551 1552 /** 1553 * Used to convert asymmetric key data to keypair object. 1554 * 1555 * @param { DataBlob | null } pubKey - the public key data blob. 1556 * @param { DataBlob | null } priKey - the private key data blob. 1557 * @param { AsyncCallback<KeyPair> } callback - the callback used to return keypair. 1558 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1559 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1560 * @throws { BusinessError } 17620001 - memory operation failed. 1561 * @throws { BusinessError } 17630001 - crypto operation error. 1562 * @syscap SystemCapability.Security.CryptoFramework 1563 * @since 10 1564 */ 1565 /** 1566 * Used to convert asymmetric key data to keypair object. 1567 * 1568 * @param { DataBlob | null } pubKey - the public key data blob. 1569 * @param { DataBlob | null } priKey - the private key data blob. 1570 * @param { AsyncCallback<KeyPair> } callback - the callback used to return keypair. 1571 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1572 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1573 * @throws { BusinessError } 17620001 - memory operation failed. 1574 * @throws { BusinessError } 17630001 - crypto operation error. 1575 * @syscap SystemCapability.Security.CryptoFramework 1576 * @crossplatform 1577 * @since 11 1578 */ 1579 /** 1580 * Used to convert asymmetric key data to keypair object. 1581 * 1582 * @param { DataBlob | null } pubKey - the public key data blob. 1583 * @param { DataBlob | null } priKey - the private key data blob. 1584 * @param { AsyncCallback<KeyPair> } callback - the callback used to return keypair. 1585 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1586 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1587 * @throws { BusinessError } 17620001 - memory operation failed. 1588 * @throws { BusinessError } 17630001 - crypto operation error. 1589 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 1590 * @crossplatform 1591 * @atomicservice 1592 * @since 12 1593 */ 1594 convertKey(pubKey: DataBlob | null, priKey: DataBlob | null, callback: AsyncCallback<KeyPair>): void; 1595 1596 /** 1597 * Used to convert asymmetric key data to keypair object. 1598 * 1599 * @param { DataBlob } pubKey - the public key data blob. 1600 * @param { DataBlob } priKey - the private key data blob. 1601 * @returns { Promise<KeyPair> } the promise used to return keypair. 1602 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1603 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1604 * @throws { BusinessError } 17620001 - memory operation failed. 1605 * @throws { BusinessError } 17630001 - crypto operation error. 1606 * @syscap SystemCapability.Security.CryptoFramework 1607 * @since 9 1608 */ 1609 /** 1610 * Used to convert asymmetric key data to keypair object. 1611 * 1612 * @param { DataBlob } pubKey - the public key data blob. 1613 * @param { DataBlob } priKey - the private key data blob. 1614 * @returns { Promise<KeyPair> } the promise used to return keypair. 1615 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1616 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1617 * @throws { BusinessError } 17620001 - memory operation failed. 1618 * @throws { BusinessError } 17630001 - crypto operation error. 1619 * @syscap SystemCapability.Security.CryptoFramework 1620 * @crossplatform 1621 * @since 11 1622 */ 1623 /** 1624 * Used to convert asymmetric key data to keypair object. 1625 * 1626 * @param { DataBlob } pubKey - the public key data blob. 1627 * @param { DataBlob } priKey - the private key data blob. 1628 * @returns { Promise<KeyPair> } the promise used to return keypair. 1629 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1630 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1631 * @throws { BusinessError } 17620001 - memory operation failed. 1632 * @throws { BusinessError } 17630001 - crypto operation error. 1633 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 1634 * @crossplatform 1635 * @atomicservice 1636 * @since 12 1637 */ 1638 convertKey(pubKey: DataBlob, priKey: DataBlob): Promise<KeyPair>; 1639 1640 /** 1641 * Used to convert asymmetric key data to keypair object. 1642 * 1643 * @param { DataBlob | null } pubKey - the public key data blob. 1644 * @param { DataBlob | null } priKey - the private key data blob. 1645 * @returns { Promise<KeyPair> } the promise used to return keypair. 1646 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1647 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1648 * @throws { BusinessError } 17620001 - memory operation failed. 1649 * @throws { BusinessError } 17630001 - crypto operation error. 1650 * @syscap SystemCapability.Security.CryptoFramework 1651 * @since 10 1652 */ 1653 /** 1654 * Used to convert asymmetric key data to keypair object. 1655 * 1656 * @param { DataBlob | null } pubKey - the public key data blob. 1657 * @param { DataBlob | null } priKey - the private key data blob. 1658 * @returns { Promise<KeyPair> } the promise used to return keypair. 1659 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1660 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1661 * @throws { BusinessError } 17620001 - memory operation failed. 1662 * @throws { BusinessError } 17630001 - crypto operation error. 1663 * @syscap SystemCapability.Security.CryptoFramework 1664 * @crossplatform 1665 * @since 11 1666 */ 1667 /** 1668 * Used to convert asymmetric key data to keypair object. 1669 * 1670 * @param { DataBlob | null } pubKey - the public key data blob. 1671 * @param { DataBlob | null } priKey - the private key data blob. 1672 * @returns { Promise<KeyPair> } the promise used to return keypair. 1673 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1674 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1675 * @throws { BusinessError } 17620001 - memory operation failed. 1676 * @throws { BusinessError } 17630001 - crypto operation error. 1677 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 1678 * @crossplatform 1679 * @atomicservice 1680 * @since 12 1681 */ 1682 convertKey(pubKey: DataBlob | null, priKey: DataBlob | null): Promise<KeyPair>; 1683 1684 /** 1685 * Used to convert asymmetric key data to keypair object. 1686 * 1687 * @param { DataBlob | null } pubKey - the public key data blob. 1688 * @param { DataBlob | null } priKey - the private key data blob. 1689 * @returns { KeyPair } return keypair. 1690 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1691 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1692 * @throws { BusinessError } 17620001 - memory operation failed. 1693 * @throws { BusinessError } 17630001 - crypto operation error. 1694 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 1695 * @crossplatform 1696 * @atomicservice 1697 * @since 12 1698 */ 1699 convertKeySync(pubKey: DataBlob | null, priKey: DataBlob | null): KeyPair; 1700 1701 /** 1702 * Used to convert asymmetric key in PEM format to keypair object. 1703 * 1704 * @param { string | null } pubKey - the public key string in PEM format. 1705 * @param { string | null } priKey - the private key string in PEM format. 1706 * @returns { Promise<KeyPair> } return keypair. 1707 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1708 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1709 * @throws { BusinessError } 17620001 - memory operation failed. 1710 * @throws { BusinessError } 17630001 - crypto operation error. 1711 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 1712 * @crossplatform 1713 * @atomicservice 1714 * @since 12 1715 */ 1716 convertPemKey(pubKey: string | null, priKey: string | null): Promise<KeyPair>; 1717 1718 /** 1719 * Used to convert asymmetric key in PEM format to keypair object. 1720 * 1721 * @param { string | null } pubKey - the public key string in PEM format. 1722 * @param { string | null } priKey - the private key string in PEM format. 1723 * @param { string } password - the password of private key. 1724 * @returns { Promise<KeyPair> } return keypair. 1725 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1726 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1727 * @throws { BusinessError } 17620001 - memory operation failed. 1728 * @throws { BusinessError } 17630001 - crypto operation error. 1729 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 1730 * @crossplatform 1731 * @atomicservice 1732 * @since 18 1733 */ 1734 convertPemKey(pubKey: string | null, priKey: string | null, password: string): Promise<KeyPair>; 1735 1736 /** 1737 * Used to convert asymmetric key in PEM format to keypair object. 1738 * 1739 * @param { string | null } pubKey - the public key string in PEM format. 1740 * @param { string | null } priKey - the private key string in PEM format. 1741 * @returns { KeyPair } return keypair. 1742 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1743 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1744 * @throws { BusinessError } 17620001 - memory operation failed. 1745 * @throws { BusinessError } 17630001 - crypto operation error. 1746 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 1747 * @crossplatform 1748 * @atomicservice 1749 * @since 12 1750 */ 1751 convertPemKeySync(pubKey: string | null, priKey: string | null): KeyPair; 1752 1753 /** 1754 * Used to convert asymmetric key in PEM format to keypair object. 1755 * 1756 * @param { string | null } pubKey - the public key string in PEM format. 1757 * @param { string | null } priKey - the private key string in PEM format. 1758 * @param { string } password - the password of private key. 1759 * @returns { KeyPair } return keypair. 1760 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1761 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1762 * @throws { BusinessError } 17620001 - memory operation failed. 1763 * @throws { BusinessError } 17630001 - crypto operation error. 1764 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 1765 * @crossplatform 1766 * @atomicservice 1767 * @since 18 1768 */ 1769 convertPemKeySync(pubKey: string | null, priKey: string | null, password: string): KeyPair; 1770 1771 /** 1772 * The algName of the AsyKeyGenerator. 1773 * 1774 * @type { string } 1775 * @readonly 1776 * @syscap SystemCapability.Security.CryptoFramework 1777 * @since 9 1778 */ 1779 /** 1780 * The algName of the AsyKeyGenerator. 1781 * 1782 * @type { string } 1783 * @readonly 1784 * @syscap SystemCapability.Security.CryptoFramework 1785 * @crossplatform 1786 * @since 11 1787 */ 1788 /** 1789 * The algName of the AsyKeyGenerator. 1790 * 1791 * @type { string } 1792 * @readonly 1793 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 1794 * @crossplatform 1795 * @atomicservice 1796 * @since 12 1797 */ 1798 readonly algName: string; 1799 } 1800 1801 /** 1802 * Provides the SymKeyGenerator type, which is used for generating symmetric key. 1803 * 1804 * @typedef SymKeyGenerator 1805 * @syscap SystemCapability.Security.CryptoFramework 1806 * @since 9 1807 */ 1808 /** 1809 * Provides the SymKeyGenerator type, which is used for generating symmetric key. 1810 * 1811 * @typedef SymKeyGenerator 1812 * @syscap SystemCapability.Security.CryptoFramework 1813 * @crossplatform 1814 * @since 11 1815 */ 1816 /** 1817 * Provides the SymKeyGenerator type, which is used for generating symmetric key. 1818 * 1819 * @typedef SymKeyGenerator 1820 * @syscap SystemCapability.Security.CryptoFramework.Key.SymKey 1821 * @crossplatform 1822 * @atomicservice 1823 * @since arkts {'1.1':'12','1.2':'20'} 1824 * @arkts 1.1&1.2 1825 */ 1826 interface SymKeyGenerator { 1827 /** 1828 * Generate a symmetric key object randomly. 1829 * 1830 * @param { AsyncCallback<SymKey> } callback - the callback of generateSymKey. 1831 * @throws { BusinessError } 17620001 - memory operation failed. 1832 * @syscap SystemCapability.Security.CryptoFramework 1833 * @since 9 1834 */ 1835 /** 1836 * Generate a symmetric key object randomly. 1837 * 1838 * @param { AsyncCallback<SymKey> } callback - the callback of generateSymKey. 1839 * @throws { BusinessError } 17620001 - memory operation failed. 1840 * @syscap SystemCapability.Security.CryptoFramework 1841 * @crossplatform 1842 * @since 11 1843 */ 1844 /** 1845 * Generate a symmetric key object randomly. 1846 * 1847 * @param { AsyncCallback<SymKey> } callback - the callback of generateSymKey. 1848 * @throws { BusinessError } 17620001 - memory operation failed. 1849 * @syscap SystemCapability.Security.CryptoFramework.Key.SymKey 1850 * @crossplatform 1851 * @atomicservice 1852 * @since 12 1853 */ 1854 generateSymKey(callback: AsyncCallback<SymKey>): void; 1855 1856 /** 1857 * Generate a symmetric key object randomly. 1858 * 1859 * @returns { Promise<SymKey> } the promise returned by the function. 1860 * @throws { BusinessError } 17620001 - memory operation failed. 1861 * @syscap SystemCapability.Security.CryptoFramework 1862 * @since 9 1863 */ 1864 /** 1865 * Generate a symmetric key object randomly. 1866 * 1867 * @returns { Promise<SymKey> } the promise returned by the function. 1868 * @throws { BusinessError } 17620001 - memory operation failed. 1869 * @syscap SystemCapability.Security.CryptoFramework 1870 * @crossplatform 1871 * @since 11 1872 */ 1873 /** 1874 * Generate a symmetric key object randomly. 1875 * 1876 * @returns { Promise<SymKey> } the promise returned by the function. 1877 * @throws { BusinessError } 17620001 - memory operation failed. 1878 * @syscap SystemCapability.Security.CryptoFramework.Key.SymKey 1879 * @crossplatform 1880 * @atomicservice 1881 * @since 12 1882 */ 1883 generateSymKey(): Promise<SymKey>; 1884 1885 /** 1886 * Generate a symmetric key object randomly. 1887 * 1888 * @returns { SymKey } return SymKey. 1889 * @throws { BusinessError } 17620001 - memory operation failed. 1890 * @syscap SystemCapability.Security.CryptoFramework.Key.SymKey 1891 * @crossplatform 1892 * @atomicservice 1893 * @since 12 1894 */ 1895 generateSymKeySync(): SymKey; 1896 1897 /** 1898 * Used to convert symmetric key data to a symmetric key object. 1899 * 1900 * @param { DataBlob } key - the key data blob. 1901 * @param { AsyncCallback<SymKey> } callback - the callback of generateSymKey. 1902 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1903 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1904 * @throws { BusinessError } 17620001 - memory operation failed. 1905 * @syscap SystemCapability.Security.CryptoFramework 1906 * @since 9 1907 */ 1908 /** 1909 * Used to convert symmetric key data to a symmetric key object. 1910 * 1911 * @param { DataBlob } key - the key data blob. 1912 * @param { AsyncCallback<SymKey> } callback - the callback of generateSymKey. 1913 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1914 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1915 * @throws { BusinessError } 17620001 - memory operation failed. 1916 * @syscap SystemCapability.Security.CryptoFramework 1917 * @crossplatform 1918 * @since 11 1919 */ 1920 /** 1921 * Used to convert symmetric key data to a symmetric key object. 1922 * 1923 * @param { DataBlob } key - the key data blob. 1924 * @param { AsyncCallback<SymKey> } callback - the callback of generateSymKey. 1925 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1926 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1927 * @throws { BusinessError } 17620001 - memory operation failed. 1928 * @syscap SystemCapability.Security.CryptoFramework.Key.SymKey 1929 * @crossplatform 1930 * @atomicservice 1931 * @since 12 1932 */ 1933 convertKey(key: DataBlob, callback: AsyncCallback<SymKey>): void; 1934 1935 /** 1936 * Used to convert symmetric key data to a symmetric key object. 1937 * 1938 * @param { DataBlob } key - the key data blob. 1939 * @returns { Promise<SymKey> } the promise returned by the function. 1940 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1941 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1942 * @throws { BusinessError } 17620001 - memory operation failed. 1943 * @syscap SystemCapability.Security.CryptoFramework 1944 * @since 9 1945 */ 1946 /** 1947 * Used to convert symmetric key data to a symmetric key object. 1948 * 1949 * @param { DataBlob } key - the key data blob. 1950 * @returns { Promise<SymKey> } the promise returned by the function. 1951 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1952 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1953 * @throws { BusinessError } 17620001 - memory operation failed. 1954 * @syscap SystemCapability.Security.CryptoFramework 1955 * @crossplatform 1956 * @since 11 1957 */ 1958 /** 1959 * Used to convert symmetric key data to a symmetric key object. 1960 * 1961 * @param { DataBlob } key - the key data blob. 1962 * @returns { Promise<SymKey> } the promise returned by the function. 1963 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1964 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1965 * @throws { BusinessError } 17620001 - memory operation failed. 1966 * @syscap SystemCapability.Security.CryptoFramework.Key.SymKey 1967 * @crossplatform 1968 * @atomicservice 1969 * @since 12 1970 */ 1971 convertKey(key: DataBlob): Promise<SymKey>; 1972 1973 /** 1974 * Used to convert symmetric key data to a symmetric key object. 1975 * 1976 * @param { DataBlob } key - the key data blob. 1977 * @returns { SymKey } return SymKey. 1978 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 1979 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 1980 * @throws { BusinessError } 17620001 - memory operation failed. 1981 * @syscap SystemCapability.Security.CryptoFramework.Key.SymKey 1982 * @crossplatform 1983 * @atomicservice 1984 * @since arkts {'1.1':'12','1.2':'20'} 1985 * @arkts 1.1&1.2 1986 */ 1987 convertKeySync(key: DataBlob): SymKey; 1988 1989 /** 1990 * Indicates the algorithm name of the SymKeyGenerator object. 1991 * 1992 * @type { string } 1993 * @readonly 1994 * @syscap SystemCapability.Security.CryptoFramework 1995 * @since 9 1996 */ 1997 /** 1998 * Indicates the algorithm name of the SymKeyGenerator object. 1999 * 2000 * @type { string } 2001 * @readonly 2002 * @syscap SystemCapability.Security.CryptoFramework 2003 * @crossplatform 2004 * @since 11 2005 */ 2006 /** 2007 * Indicates the algorithm name of the SymKeyGenerator object. 2008 * 2009 * @type { string } 2010 * @readonly 2011 * @syscap SystemCapability.Security.CryptoFramework.Key.SymKey 2012 * @crossplatform 2013 * @atomicservice 2014 * @since 12 2015 */ 2016 readonly algName: string; 2017 } 2018 2019 /** 2020 * Create the asymmetric key generator instance according to the given algorithm name. 2021 * 2022 * @param { string } algName - indicates the algorithm name. Multiple parameters need to be concatenated by "|". 2023 * @returns { AsyKeyGenerator } the asymmetric key generator instance. 2024 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2025 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2026 * @throws { BusinessError } 801 - this operation is not supported. 2027 * @throws { BusinessError } 17620001 - memory operation failed. 2028 * @syscap SystemCapability.Security.CryptoFramework 2029 * @since 9 2030 */ 2031 /** 2032 * Create the asymmetric key generator instance according to the given algorithm name. 2033 * 2034 * @param { string } algName - indicates the algorithm name. 2035 * @returns { AsyKeyGenerator } the asymmetric key generator instance. Multiple parameters need to be concatenated by "|". 2036 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2037 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2038 * @throws { BusinessError } 801 - this operation is not supported. 2039 * @throws { BusinessError } 17620001 - memory operation failed. 2040 * @syscap SystemCapability.Security.CryptoFramework 2041 * @crossplatform 2042 * @since 11 2043 */ 2044 /** 2045 * Create the asymmetric key generator instance according to the given algorithm name. 2046 * 2047 * @param { string } algName - indicates the algorithm name. Multiple parameters need to be concatenated by "|". 2048 * @returns { AsyKeyGenerator } the asymmetric key generator instance. 2049 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2050 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2051 * @throws { BusinessError } 801 - this operation is not supported. 2052 * @throws { BusinessError } 17620001 - memory operation failed. 2053 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 2054 * @crossplatform 2055 * @atomicservice 2056 * @since 12 2057 */ 2058 function createAsyKeyGenerator(algName: string): AsyKeyGenerator; 2059 2060 /** 2061 * Create a symmetric key generator according to the given algorithm name. 2062 * 2063 * @param { string } algName - indicates the algorithm name. 2064 * @returns { SymKeyGenerator } the symmetric key generator instance. Multiple parameters need to be concatenated by "|". 2065 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2066 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2067 * @throws { BusinessError } 801 - this operation is not supported. 2068 * @syscap SystemCapability.Security.CryptoFramework 2069 * @since 9 2070 */ 2071 /** 2072 * Create a symmetric key generator according to the given algorithm name. 2073 * 2074 * @param { string } algName - indicates the algorithm name. Multiple parameters need to be concatenated by "|". 2075 * @returns { SymKeyGenerator } the symmetric key generator instance. 2076 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2077 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2078 * @throws { BusinessError } 801 - this operation is not supported. 2079 * @syscap SystemCapability.Security.CryptoFramework 2080 * @crossplatform 2081 * @since 11 2082 */ 2083 /** 2084 * Create a symmetric key generator according to the given algorithm name. 2085 * 2086 * @param { string } algName - indicates the algorithm name. Multiple parameters need to be concatenated by "|". 2087 * @returns { SymKeyGenerator } the symmetric key generator instance. 2088 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2089 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2090 * @throws { BusinessError } 801 - this operation is not supported. 2091 * @syscap SystemCapability.Security.CryptoFramework.Key.SymKey 2092 * @crossplatform 2093 * @atomicservice 2094 * @since arkts {'1.1':'12','1.2':'20'} 2095 * @arkts 1.1&1.2 2096 */ 2097 function createSymKeyGenerator(algName: string): SymKeyGenerator; 2098 2099 /** 2100 * Represents the message authentication code (MAC) parameters. 2101 * You need to construct a child class object and use it as a parameter when generating a HMAC or CMAC. 2102 * 2103 * @typedef MacSpec 2104 * @syscap SystemCapability.Security.CryptoFramework.Mac 2105 * @crossplatform 2106 * @atomicservice 2107 * @since 18 2108 */ 2109 interface MacSpec { 2110 /** 2111 * Indicates the algorithm name of the Mac. 2112 * 2113 * @type { string } 2114 * @syscap SystemCapability.Security.CryptoFramework.Mac 2115 * @crossplatform 2116 * @atomicservice 2117 * @since 18 2118 */ 2119 algName: string; 2120 } 2121 2122 /** 2123 * Represents the child class of MacSpec. It is used as an input parameter for HMAC generation. 2124 * 2125 * @extends MacSpec 2126 * @typedef HmacSpec 2127 * @syscap SystemCapability.Security.CryptoFramework.Mac 2128 * @crossplatform 2129 * @atomicservice 2130 * @since 18 2131 */ 2132 interface HmacSpec extends MacSpec { 2133 /** 2134 * Indicates the message digest algorithm name of the HMAC. 2135 * 2136 * @type { string } 2137 * @syscap SystemCapability.Security.CryptoFramework.Mac 2138 * @crossplatform 2139 * @atomicservice 2140 * @since 18 2141 */ 2142 mdName: string; 2143 } 2144 2145 /** 2146 * Represents the child class of MacSpec. It is used as an input parameter for CMAC generation. 2147 * 2148 * @extends MacSpec 2149 * @typedef CmacSpec 2150 * @syscap SystemCapability.Security.CryptoFramework.Mac 2151 * @crossplatform 2152 * @atomicservice 2153 * @since 18 2154 */ 2155 interface CmacSpec extends MacSpec { 2156 /** 2157 * Indicates the cipher algorithm name of the CMAC. 2158 * 2159 * @type { string } 2160 * @syscap SystemCapability.Security.CryptoFramework.Mac 2161 * @crossplatform 2162 * @atomicservice 2163 * @since 18 2164 */ 2165 cipherName: string; 2166 } 2167 2168 /** 2169 * Provides the Mac type, which is used for Mac generation. 2170 * 2171 * @typedef Mac 2172 * @syscap SystemCapability.Security.CryptoFramework 2173 * @since 9 2174 */ 2175 /** 2176 * Provides the Mac type, which is used for Mac generation. 2177 * 2178 * @typedef Mac 2179 * @syscap SystemCapability.Security.CryptoFramework 2180 * @crossplatform 2181 * @since 11 2182 */ 2183 /** 2184 * Provides the Mac type, which is used for Mac generation. 2185 * Before using any API of the Mac class, you must create a Mac instance by using createMac. 2186 * 2187 * @typedef Mac 2188 * @syscap SystemCapability.Security.CryptoFramework.Mac 2189 * @crossplatform 2190 * @atomicservice 2191 * @since arkts {'1.1':'12','1.2':'20'} 2192 * @arkts 1.1&1.2 2193 */ 2194 interface Mac { 2195 /** 2196 * Init mac with given SymKey. 2197 * 2198 * @param { SymKey } key - indicates the SymKey. 2199 * @param { AsyncCallback<void> } callback - the callback of the init function. 2200 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2201 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2202 * @throws { BusinessError } 17620001 - memory operation failed. 2203 * @throws { BusinessError } 17630001 - crypto operation error. 2204 * @syscap SystemCapability.Security.CryptoFramework 2205 * @since 9 2206 */ 2207 /** 2208 * Init mac with given SymKey. 2209 * 2210 * @param { SymKey } key - indicates the SymKey. 2211 * @param { AsyncCallback<void> } callback - the callback of the init function. 2212 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2213 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2214 * @throws { BusinessError } 17620001 - memory operation failed. 2215 * @throws { BusinessError } 17630001 - crypto operation error. 2216 * @syscap SystemCapability.Security.CryptoFramework 2217 * @crossplatform 2218 * @since 11 2219 */ 2220 /** 2221 * Init mac with given SymKey. 2222 * This API uses an asynchronous callback to return the result. init, update, and doFinal must be used together. 2223 * init and doFinal are mandatory, and update is optional. 2224 * 2225 * @param { SymKey } key - indicates the SymKey. 2226 * @param { AsyncCallback<void> } callback - the callback of the init function. 2227 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2228 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2229 * @throws { BusinessError } 17620001 - memory operation failed. 2230 * @throws { BusinessError } 17630001 - crypto operation error. 2231 * @syscap SystemCapability.Security.CryptoFramework.Mac 2232 * @crossplatform 2233 * @atomicservice 2234 * @since 12 2235 */ 2236 init(key: SymKey, callback: AsyncCallback<void>): void; 2237 2238 /** 2239 * Init mac with given SymKey. 2240 * 2241 * @param { SymKey } key - indicates the SymKey. 2242 * @returns { Promise<void> } the promise returned by the function. 2243 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2244 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2245 * @throws { BusinessError } 17620001 - memory operation failed. 2246 * @throws { BusinessError } 17630001 - crypto operation error. 2247 * @syscap SystemCapability.Security.CryptoFramework 2248 * @since 9 2249 */ 2250 /** 2251 * Init mac with given SymKey. 2252 * 2253 * @param { SymKey } key - indicates the SymKey. 2254 * @returns { Promise<void> } the promise returned by the function. 2255 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2256 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2257 * @throws { BusinessError } 17620001 - memory operation failed. 2258 * @throws { BusinessError } 17630001 - crypto operation error. 2259 * @syscap SystemCapability.Security.CryptoFramework 2260 * @crossplatform 2261 * @since 11 2262 */ 2263 /** 2264 * Init mac with given SymKey. 2265 * This API uses an asynchronous callback to return the result. init, update, and doFinal must be used together. 2266 * init and doFinal are mandatory, and update is optional. 2267 * 2268 * @param { SymKey } key - indicates the SymKey. 2269 * @returns { Promise<void> } the promise returned by the function. 2270 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2271 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2272 * @throws { BusinessError } 17620001 - memory operation failed. 2273 * @throws { BusinessError } 17630001 - crypto operation error. 2274 * @syscap SystemCapability.Security.CryptoFramework.Mac 2275 * @crossplatform 2276 * @atomicservice 2277 * @since 12 2278 */ 2279 init(key: SymKey): Promise<void>; 2280 2281 /** 2282 * Init mac with given SymKey. 2283 * This API uses an asynchronous callback to return the result. init, update, and doFinal must be used together. 2284 * init and doFinal are mandatory, and update is optional. 2285 * 2286 * @param { SymKey } key - indicates the SymKey. 2287 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2288 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2289 * @throws { BusinessError } 17620001 - memory operation failed. 2290 * @throws { BusinessError } 17630001 - crypto operation error. 2291 * @syscap SystemCapability.Security.CryptoFramework.Mac 2292 * @crossplatform 2293 * @atomicservice 2294 * @since arkts {'1.1':'12','1.2':'20'} 2295 * @arkts 1.1&1.2 2296 */ 2297 initSync(key: SymKey): void; 2298 2299 /** 2300 * Update mac with DataBlob. 2301 * 2302 * @param { DataBlob } input - indicates the DataBlob. 2303 * @param { AsyncCallback<void> } callback - the callback of the update function. 2304 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2305 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2306 * @throws { BusinessError } 17620001 - memory operation failed. 2307 * @throws { BusinessError } 17630001 - crypto operation error. 2308 * @syscap SystemCapability.Security.CryptoFramework 2309 * @since 9 2310 */ 2311 /** 2312 * Update mac with DataBlob. 2313 * 2314 * @param { DataBlob } input - indicates the DataBlob. 2315 * @param { AsyncCallback<void> } callback - the callback of the update function. 2316 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2317 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2318 * @throws { BusinessError } 17620001 - memory operation failed. 2319 * @throws { BusinessError } 17630001 - crypto operation error. 2320 * @syscap SystemCapability.Security.CryptoFramework 2321 * @crossplatform 2322 * @since 11 2323 */ 2324 /** 2325 * Update mac with DataBlob. 2326 * 2327 * @param { DataBlob } input - indicates the DataBlob. 2328 * @param { AsyncCallback<void> } callback - the callback of the update function. 2329 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2330 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2331 * @throws { BusinessError } 17620001 - memory operation failed. 2332 * @throws { BusinessError } 17630001 - crypto operation error. 2333 * @syscap SystemCapability.Security.CryptoFramework.Mac 2334 * @crossplatform 2335 * @atomicservice 2336 * @since 12 2337 */ 2338 update(input: DataBlob, callback: AsyncCallback<void>): void; 2339 2340 /** 2341 * Update mac with DataBlob. 2342 * 2343 * @param { DataBlob } input - indicates the DataBlob. 2344 * @returns { Promise<void> } the promise returned by the function. 2345 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2346 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2347 * @throws { BusinessError } 17620001 - memory operation failed. 2348 * @throws { BusinessError } 17630001 - crypto operation error. 2349 * @syscap SystemCapability.Security.CryptoFramework 2350 * @since 9 2351 */ 2352 /** 2353 * Update mac with DataBlob. 2354 * 2355 * @param { DataBlob } input - indicates the DataBlob. 2356 * @returns { Promise<void> } the promise returned by the function. 2357 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2358 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2359 * @throws { BusinessError } 17620001 - memory operation failed. 2360 * @throws { BusinessError } 17630001 - crypto operation error. 2361 * @syscap SystemCapability.Security.CryptoFramework 2362 * @crossplatform 2363 * @since 11 2364 */ 2365 /** 2366 * Update mac with DataBlob. 2367 * 2368 * @param { DataBlob } input - indicates the DataBlob. 2369 * @returns { Promise<void> } the promise returned by the function. 2370 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2371 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2372 * @throws { BusinessError } 17620001 - memory operation failed. 2373 * @throws { BusinessError } 17630001 - crypto operation error. 2374 * @syscap SystemCapability.Security.CryptoFramework.Mac 2375 * @crossplatform 2376 * @atomicservice 2377 * @since 12 2378 */ 2379 update(input: DataBlob): Promise<void>; 2380 2381 /** 2382 * Update mac with DataBlob. 2383 * 2384 * @param { DataBlob } input - indicates the DataBlob. 2385 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2386 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2387 * @throws { BusinessError } 17620001 - memory operation failed. 2388 * @throws { BusinessError } 17630001 - crypto operation error. 2389 * @syscap SystemCapability.Security.CryptoFramework.Mac 2390 * @crossplatform 2391 * @atomicservice 2392 * @since arkts {'1.1':'12','1.2':'20'} 2393 * @arkts 1.1&1.2 2394 */ 2395 updateSync(input: DataBlob): void; 2396 2397 /** 2398 * Output the result of mac calculation. 2399 * 2400 * @param { AsyncCallback<DataBlob> } callback - the callback of the doFinal function. 2401 * @throws { BusinessError } 17620001 - memory operation failed. 2402 * @throws { BusinessError } 17630001 - crypto operation error. 2403 * @syscap SystemCapability.Security.CryptoFramework 2404 * @since 9 2405 */ 2406 /** 2407 * Output the result of mac calculation. 2408 * 2409 * @param { AsyncCallback<DataBlob> } callback - the callback of the doFinal function. 2410 * @throws { BusinessError } 17620001 - memory operation failed. 2411 * @throws { BusinessError } 17630001 - crypto operation error. 2412 * @syscap SystemCapability.Security.CryptoFramework 2413 * @crossplatform 2414 * @since 11 2415 */ 2416 /** 2417 * Output the result of mac calculation. 2418 * 2419 * @param { AsyncCallback<DataBlob> } callback - the callback of the doFinal function. 2420 * @throws { BusinessError } 17620001 - memory operation failed. 2421 * @throws { BusinessError } 17630001 - crypto operation error. 2422 * @syscap SystemCapability.Security.CryptoFramework.Mac 2423 * @crossplatform 2424 * @atomicservice 2425 * @since 12 2426 */ 2427 doFinal(callback: AsyncCallback<DataBlob>): void; 2428 2429 /** 2430 * Output the result of mac calculation. 2431 * 2432 * @returns { Promise<DataBlob> } the promise returned by the function. 2433 * @throws { BusinessError } 17620001 - memory operation failed. 2434 * @throws { BusinessError } 17630001 - crypto operation error. 2435 * @syscap SystemCapability.Security.CryptoFramework 2436 * @since 9 2437 */ 2438 /** 2439 * Output the result of mac calculation. 2440 * 2441 * @returns { Promise<DataBlob> } the promise returned by the function. 2442 * @throws { BusinessError } 17620001 - memory operation failed. 2443 * @throws { BusinessError } 17630001 - crypto operation error. 2444 * @syscap SystemCapability.Security.CryptoFramework 2445 * @crossplatform 2446 * @since 11 2447 */ 2448 /** 2449 * Output the result of mac calculation. 2450 * 2451 * @returns { Promise<DataBlob> } the promise returned by the function. 2452 * @throws { BusinessError } 17620001 - memory operation failed. 2453 * @throws { BusinessError } 17630001 - crypto operation error. 2454 * @syscap SystemCapability.Security.CryptoFramework.Mac 2455 * @crossplatform 2456 * @atomicservice 2457 * @since 12 2458 */ 2459 doFinal(): Promise<DataBlob>; 2460 2461 /** 2462 * Output the result of mac calculation. 2463 * 2464 * @returns { DataBlob } the sync returned by the function. 2465 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2466 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2467 * @throws { BusinessError } 17620001 - memory operation failed. 2468 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 2469 * @throws { BusinessError } 17630001 - crypto operation error. 2470 * @syscap SystemCapability.Security.CryptoFramework.Mac 2471 * @crossplatform 2472 * @atomicservice 2473 * @since arkts {'1.1':'12','1.2':'20'} 2474 * @arkts 1.1&1.2 2475 */ 2476 doFinalSync(): DataBlob; 2477 2478 /** 2479 * Output the length of mac result. 2480 * 2481 * @returns { number } returns the length of the mac result. 2482 * @throws { BusinessError } 17630001 - crypto operation error. 2483 * @syscap SystemCapability.Security.CryptoFramework 2484 * @since 9 2485 */ 2486 /** 2487 * Output the length of mac result. 2488 * 2489 * @returns { number } returns the length of the mac result. 2490 * @throws { BusinessError } 17630001 - crypto operation error. 2491 * @syscap SystemCapability.Security.CryptoFramework 2492 * @crossplatform 2493 * @since 11 2494 */ 2495 /** 2496 * Output the length of mac result. 2497 * 2498 * @returns { number } returns the length of the mac result. 2499 * @throws { BusinessError } 17630001 - crypto operation error. 2500 * @syscap SystemCapability.Security.CryptoFramework.Mac 2501 * @crossplatform 2502 * @atomicservice 2503 * @since 12 2504 */ 2505 getMacLength(): number; 2506 2507 /** 2508 * Indicates the algorithm name. 2509 * 2510 * @type { string } 2511 * @readonly 2512 * @syscap SystemCapability.Security.CryptoFramework 2513 * @since 9 2514 */ 2515 /** 2516 * Indicates the algorithm name. 2517 * 2518 * @type { string } 2519 * @readonly 2520 * @syscap SystemCapability.Security.CryptoFramework 2521 * @crossplatform 2522 * @since 11 2523 */ 2524 /** 2525 * Indicates the algorithm name. 2526 * 2527 * @type { string } 2528 * @readonly 2529 * @syscap SystemCapability.Security.CryptoFramework.Mac 2530 * @crossplatform 2531 * @atomicservice 2532 * @since 12 2533 */ 2534 readonly algName: string; 2535 } 2536 2537 /** 2538 * Provides the mac create func. 2539 * 2540 * @param { string } algName - indicates the mac algorithm name. 2541 * @returns { Mac } returns the created mac instance. 2542 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2543 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2544 * @throws { BusinessError } 17620001 - memory operation failed. 2545 * @syscap SystemCapability.Security.CryptoFramework 2546 * @since 9 2547 */ 2548 /** 2549 * Provides the mac create func. 2550 * 2551 * @param { string } algName - indicates the mac algorithm name. 2552 * @returns { Mac } returns the created mac instance. 2553 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2554 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2555 * @throws { BusinessError } 17620001 - memory operation failed. 2556 * @syscap SystemCapability.Security.CryptoFramework 2557 * @crossplatform 2558 * @since 11 2559 */ 2560 /** 2561 * Creates a Mac instance for MAC operations. 2562 * 2563 * @param { string } algName - indicates the mac algorithm name. 2564 * @returns { Mac } returns the created mac instance. 2565 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2566 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2567 * @throws { BusinessError } 17620001 - memory operation failed. 2568 * @syscap SystemCapability.Security.CryptoFramework.Mac 2569 * @crossplatform 2570 * @atomicservice 2571 * @since arkts {'1.1':'12','1.2':'20'} 2572 * @arkts 1.1&1.2 2573 */ 2574 function createMac(algName: string): Mac; 2575 2576 /** 2577 * Creates a Mac instance for MAC operations. 2578 * 2579 * @param { MacSpec } macSpec - indicates the mac parameters. 2580 * @returns { Mac } returns the created mac instance. 2581 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2582 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2583 * @throws { BusinessError } 17620001 - memory operation failed. 2584 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 2585 * @throws { BusinessError } 17630001 - crypto operation error. 2586 * @syscap SystemCapability.Security.CryptoFramework.Mac 2587 * @crossplatform 2588 * @atomicservice 2589 * @since 18 2590 */ 2591 function createMac(macSpec: MacSpec): Mac; 2592 2593 /** 2594 * Provides the Md type, which is used for Md generation. 2595 * 2596 * @typedef Md 2597 * @syscap SystemCapability.Security.CryptoFramework 2598 * @since 9 2599 */ 2600 /** 2601 * Provides the Md type, which is used for Md generation. 2602 * 2603 * @typedef Md 2604 * @syscap SystemCapability.Security.CryptoFramework 2605 * @crossplatform 2606 * @since 11 2607 */ 2608 /** 2609 * Provides the Md type, which is used for Md generation. 2610 * Before using any API of the Md class, you must create an Md instance by using createMd. 2611 * 2612 * @typedef Md 2613 * @syscap SystemCapability.Security.CryptoFramework.MessageDigest 2614 * @crossplatform 2615 * @atomicservice 2616 * @since 12 2617 */ 2618 interface Md { 2619 /** 2620 * Update md with DataBlob. 2621 * 2622 * @param { DataBlob } input - indicates the DataBlob. 2623 * @param { AsyncCallback<void> } callback - the callback of the update function. 2624 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2625 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2626 * @throws { BusinessError } 17620001 - memory operation failed. 2627 * @throws { BusinessError } 17630001 - crypto operation error. 2628 * @syscap SystemCapability.Security.CryptoFramework 2629 * @since 9 2630 */ 2631 /** 2632 * Update md with DataBlob. 2633 * 2634 * @param { DataBlob } input - indicates the DataBlob. 2635 * @param { AsyncCallback<void> } callback - the callback of the update function. 2636 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2637 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2638 * @throws { BusinessError } 17620001 - memory operation failed. 2639 * @throws { BusinessError } 17630001 - crypto operation error. 2640 * @syscap SystemCapability.Security.CryptoFramework 2641 * @crossplatform 2642 * @since 11 2643 */ 2644 /** 2645 * Update md with DataBlob. 2646 * 2647 * @param { DataBlob } input - indicates the DataBlob. 2648 * @param { AsyncCallback<void> } callback - the callback of the update function. 2649 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2650 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2651 * @throws { BusinessError } 17620001 - memory operation failed. 2652 * @throws { BusinessError } 17630001 - crypto operation error. 2653 * @syscap SystemCapability.Security.CryptoFramework.MessageDigest 2654 * @crossplatform 2655 * @atomicservice 2656 * @since 12 2657 */ 2658 update(input: DataBlob, callback: AsyncCallback<void>): void; 2659 2660 /** 2661 * Update md with DataBlob. 2662 * 2663 * @param { DataBlob } input - indicates the DataBlob. 2664 * @returns { Promise<void> } the promise returned by the function. 2665 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2666 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2667 * @throws { BusinessError } 17620001 - memory operation failed. 2668 * @throws { BusinessError } 17630001 - crypto operation error. 2669 * @syscap SystemCapability.Security.CryptoFramework 2670 * @since 9 2671 */ 2672 /** 2673 * Update md with DataBlob. 2674 * 2675 * @param { DataBlob } input - indicates the DataBlob. 2676 * @returns { Promise<void> } the promise returned by the function. 2677 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2678 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2679 * @throws { BusinessError } 17620001 - memory operation failed. 2680 * @throws { BusinessError } 17630001 - crypto operation error. 2681 * @syscap SystemCapability.Security.CryptoFramework 2682 * @crossplatform 2683 * @since 11 2684 */ 2685 /** 2686 * Update md with DataBlob. 2687 * 2688 * @param { DataBlob } input - indicates the DataBlob. 2689 * @returns { Promise<void> } the promise returned by the function. 2690 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2691 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2692 * @throws { BusinessError } 17620001 - memory operation failed. 2693 * @throws { BusinessError } 17630001 - crypto operation error. 2694 * @syscap SystemCapability.Security.CryptoFramework.MessageDigest 2695 * @crossplatform 2696 * @atomicservice 2697 * @since 12 2698 */ 2699 update(input: DataBlob): Promise<void>; 2700 2701 /** 2702 * Update md with DataBlob. 2703 * 2704 * @param { DataBlob } input - indicates the DataBlob. 2705 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2706 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2707 * @throws { BusinessError } 17620001 - memory operation failed. 2708 * @throws { BusinessError } 17630001 - crypto operation error. 2709 * @syscap SystemCapability.Security.CryptoFramework.MessageDigest 2710 * @crossplatform 2711 * @atomicservice 2712 * @since 12 2713 */ 2714 updateSync(input: DataBlob): void; 2715 2716 /** 2717 * Output the result of md calculation. 2718 * 2719 * @param { AsyncCallback<DataBlob> } callback - the callback of the digest function. 2720 * @throws { BusinessError } 17620001 - memory operation failed. 2721 * @throws { BusinessError } 17630001 - crypto operation error. 2722 * @syscap SystemCapability.Security.CryptoFramework 2723 * @since 9 2724 */ 2725 /** 2726 * Output the result of md calculation. 2727 * 2728 * @param { AsyncCallback<DataBlob> } callback - the callback of the digest function. 2729 * @throws { BusinessError } 17620001 - memory operation failed. 2730 * @throws { BusinessError } 17630001 - crypto operation error. 2731 * @syscap SystemCapability.Security.CryptoFramework 2732 * @crossplatform 2733 * @since 11 2734 */ 2735 /** 2736 * Output the result of md calculation. 2737 * 2738 * @param { AsyncCallback<DataBlob> } callback - the callback of the digest function. 2739 * @throws { BusinessError } 17620001 - memory operation failed. 2740 * @throws { BusinessError } 17630001 - crypto operation error. 2741 * @syscap SystemCapability.Security.CryptoFramework.MessageDigest 2742 * @crossplatform 2743 * @atomicservice 2744 * @since 12 2745 */ 2746 digest(callback: AsyncCallback<DataBlob>): void; 2747 2748 /** 2749 * Output the result of md calculation. 2750 * 2751 * @returns { Promise<DataBlob> } the promise returned by the function. 2752 * @throws { BusinessError } 17620001 - memory operation failed. 2753 * @throws { BusinessError } 17630001 - crypto operation error. 2754 * @syscap SystemCapability.Security.CryptoFramework 2755 * @since 9 2756 */ 2757 /** 2758 * Output the result of md calculation. 2759 * 2760 * @returns { Promise<DataBlob> } the promise returned by the function. 2761 * @throws { BusinessError } 17620001 - memory operation failed. 2762 * @throws { BusinessError } 17630001 - crypto operation error. 2763 * @syscap SystemCapability.Security.CryptoFramework 2764 * @crossplatform 2765 * @since 11 2766 */ 2767 /** 2768 * Output the result of md calculation. 2769 * 2770 * @returns { Promise<DataBlob> } the promise returned by the function. 2771 * @throws { BusinessError } 17620001 - memory operation failed. 2772 * @throws { BusinessError } 17630001 - crypto operation error. 2773 * @syscap SystemCapability.Security.CryptoFramework.MessageDigest 2774 * @crossplatform 2775 * @atomicservice 2776 * @since 12 2777 */ 2778 digest(): Promise<DataBlob>; 2779 2780 /** 2781 * Output the result of md calculation. 2782 * 2783 * @returns { DataBlob } the sync returned by the function. 2784 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2785 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2786 * @throws { BusinessError } 17620001 - memory operation failed. 2787 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 2788 * @throws { BusinessError } 17630001 - crypto operation error. 2789 * @syscap SystemCapability.Security.CryptoFramework.MessageDigest 2790 * @crossplatform 2791 * @atomicservice 2792 * @since 12 2793 */ 2794 digestSync(): DataBlob; 2795 2796 /** 2797 * Output the length of md result. 2798 * 2799 * @returns { number } returns the length of the md result. 2800 * @throws { BusinessError } 17630001 - crypto operation error. 2801 * @syscap SystemCapability.Security.CryptoFramework 2802 * @since 9 2803 */ 2804 /** 2805 * Output the length of md result. 2806 * 2807 * @returns { number } returns the length of the md result. 2808 * @throws { BusinessError } 17630001 - crypto operation error. 2809 * @syscap SystemCapability.Security.CryptoFramework 2810 * @crossplatform 2811 * @since 11 2812 */ 2813 /** 2814 * Output the length of md result. 2815 * 2816 * @returns { number } returns the length of the md result. 2817 * @throws { BusinessError } 17630001 - crypto operation error. 2818 * @syscap SystemCapability.Security.CryptoFramework.MessageDigest 2819 * @crossplatform 2820 * @atomicservice 2821 * @since 12 2822 */ 2823 getMdLength(): number; 2824 2825 /** 2826 * Indicates the algorithm name. 2827 * 2828 * @type { string } 2829 * @readonly 2830 * @syscap SystemCapability.Security.CryptoFramework 2831 * @since 9 2832 */ 2833 /** 2834 * Indicates the algorithm name. 2835 * 2836 * @type { string } 2837 * @readonly 2838 * @syscap SystemCapability.Security.CryptoFramework 2839 * @crossplatform 2840 * @since 11 2841 */ 2842 /** 2843 * Indicates the algorithm name. 2844 * 2845 * @type { string } 2846 * @readonly 2847 * @syscap SystemCapability.Security.CryptoFramework.MessageDigest 2848 * @crossplatform 2849 * @atomicservice 2850 * @since 12 2851 */ 2852 readonly algName: string; 2853 } 2854 2855 /** 2856 * Provides the md create func. 2857 * 2858 * @param { string } algName - indicates the md algorithm name. 2859 * @returns { Md } returns the created md instance. 2860 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2861 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2862 * @throws { BusinessError } 17620001 - memory operation failed. 2863 * @syscap SystemCapability.Security.CryptoFramework 2864 * @since 9 2865 */ 2866 /** 2867 * Provides the md create func. 2868 * 2869 * @param { string } algName - indicates the md algorithm name. 2870 * @returns { Md } returns the created md instance. 2871 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2872 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2873 * @throws { BusinessError } 17620001 - memory operation failed. 2874 * @syscap SystemCapability.Security.CryptoFramework 2875 * @crossplatform 2876 * @since 11 2877 */ 2878 /** 2879 * Creates an Md instance for MD operations. 2880 * 2881 * @param { string } algName - indicates the md algorithm name. 2882 * @returns { Md } returns the created md instance. 2883 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 2884 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 2885 * @throws { BusinessError } 17620001 - memory operation failed. 2886 * @syscap SystemCapability.Security.CryptoFramework.MessageDigest 2887 * @crossplatform 2888 * @atomicservice 2889 * @since 12 2890 */ 2891 function createMd(algName: string): Md; 2892 2893 /** 2894 * Enum for encryption specified parameters. 2895 * 2896 * @enum { number } 2897 * @syscap SystemCapability.Security.CryptoFramework 2898 * @since 10 2899 */ 2900 /** 2901 * Enum for encryption specified parameters. 2902 * 2903 * @enum { number } 2904 * @syscap SystemCapability.Security.CryptoFramework 2905 * @crossplatform 2906 * @since 11 2907 */ 2908 /** 2909 * Enum for encryption specified parameters. 2910 * You can use setCipherSpec to set cipher parameters, and use getCipherSpec to obtain cipher parameters. 2911 * 2912 * @enum { number } 2913 * @syscap SystemCapability.Security.CryptoFramework.Cipher 2914 * @crossplatform 2915 * @atomicservice 2916 * @since 12 2917 */ 2918 enum CipherSpecItem { 2919 /** 2920 * Indicates the algorithm name of the message digest function. It is used during RSA encryption. 2921 * 2922 * @syscap SystemCapability.Security.CryptoFramework 2923 * @since 10 2924 */ 2925 /** 2926 * Indicates the algorithm name of the message digest function. It is used during RSA encryption. 2927 * 2928 * @syscap SystemCapability.Security.CryptoFramework 2929 * @crossplatform 2930 * @since 11 2931 */ 2932 /** 2933 * Indicates the algorithm name of the message digest function. It is used during RSA encryption. 2934 * 2935 * @syscap SystemCapability.Security.CryptoFramework.Cipher 2936 * @crossplatform 2937 * @atomicservice 2938 * @since 12 2939 */ 2940 OAEP_MD_NAME_STR = 100, 2941 2942 /** 2943 * Indicates the algorithm name for the mask generation function. It is used during RSA encryption. 2944 * 2945 * @syscap SystemCapability.Security.CryptoFramework 2946 * @since 10 2947 */ 2948 /** 2949 * Indicates the algorithm name for the mask generation function. It is used during RSA encryption. 2950 * 2951 * @syscap SystemCapability.Security.CryptoFramework 2952 * @crossplatform 2953 * @since 11 2954 */ 2955 /** 2956 * Indicates the algorithm name for the mask generation function. It is used during RSA encryption. 2957 * 2958 * @syscap SystemCapability.Security.CryptoFramework.Cipher 2959 * @crossplatform 2960 * @atomicservice 2961 * @since 12 2962 */ 2963 OAEP_MGF_NAME_STR = 101, 2964 2965 /** 2966 * Indicates the message digest parameter for the MGF1 mask generation function. It is used during RSA encryption. 2967 * 2968 * @syscap SystemCapability.Security.CryptoFramework 2969 * @since 10 2970 */ 2971 /** 2972 * Indicates the message digest parameter for the MGF1 mask generation function. It is used during RSA encryption. 2973 * 2974 * @syscap SystemCapability.Security.CryptoFramework 2975 * @crossplatform 2976 * @since 11 2977 */ 2978 /** 2979 * Indicates the message digest parameter for the MGF1 mask generation function. It is used during RSA encryption. 2980 * 2981 * @syscap SystemCapability.Security.CryptoFramework.Cipher 2982 * @crossplatform 2983 * @atomicservice 2984 * @since 12 2985 */ 2986 OAEP_MGF1_MD_STR = 102, 2987 2988 /** 2989 * Indicates the source of the encoding input P. It is used during RSA encryption. 2990 * 2991 * @syscap SystemCapability.Security.CryptoFramework 2992 * @since 10 2993 */ 2994 /** 2995 * Indicates the source of the encoding input P. It is used during RSA encryption. 2996 * 2997 * @syscap SystemCapability.Security.CryptoFramework 2998 * @crossplatform 2999 * @since 11 3000 */ 3001 /** 3002 * Indicates the source of the encoding input P. It is used during RSA encryption. 3003 * 3004 * @syscap SystemCapability.Security.CryptoFramework.Cipher 3005 * @crossplatform 3006 * @atomicservice 3007 * @since 12 3008 */ 3009 OAEP_MGF1_PSRC_UINT8ARR = 103, 3010 3011 /** 3012 * Indicates the hash algorithm name of SM2 cipher process. 3013 * 3014 * @syscap SystemCapability.Security.CryptoFramework 3015 * @crossplatform 3016 * @since 11 3017 */ 3018 /** 3019 * Indicates the hash algorithm name of SM2 cipher process. 3020 * 3021 * @syscap SystemCapability.Security.CryptoFramework.Cipher 3022 * @crossplatform 3023 * @atomicservice 3024 * @since 12 3025 */ 3026 SM2_MD_NAME_STR = 104 3027 } 3028 3029 /** 3030 * Enum for signature specified parameters, also used for verification. 3031 * 3032 * @enum { number } 3033 * @syscap SystemCapability.Security.CryptoFramework 3034 * @since 10 3035 */ 3036 /** 3037 * Enum for signature specified parameters, also used for verification. 3038 * 3039 * @enum { number } 3040 * @syscap SystemCapability.Security.CryptoFramework 3041 * @crossplatform 3042 * @since 11 3043 */ 3044 /** 3045 * Enum for signature specified parameters, also used for verification. 3046 * You can use setSignSpec and setVerifySpec to set these parameters, and use getSignSpec and getVerifySpec to obtain the parameters. 3047 * 3048 * @enum { number } 3049 * @syscap SystemCapability.Security.CryptoFramework.Signature 3050 * @crossplatform 3051 * @atomicservice 3052 * @since 12 3053 */ 3054 enum SignSpecItem { 3055 /** 3056 * Indicates the algorithm name of the message digest function. It is used in RSA signing and verifying process. 3057 * 3058 * @syscap SystemCapability.Security.CryptoFramework 3059 * @since 10 3060 */ 3061 /** 3062 * Indicates the algorithm name of the message digest function. It is used in RSA signing and verifying process. 3063 * 3064 * @syscap SystemCapability.Security.CryptoFramework 3065 * @crossplatform 3066 * @since 11 3067 */ 3068 /** 3069 * Indicates the algorithm name of the message digest function. It is used in RSA signing and verifying process. 3070 * 3071 * @syscap SystemCapability.Security.CryptoFramework.Signature 3072 * @crossplatform 3073 * @atomicservice 3074 * @since 12 3075 */ 3076 PSS_MD_NAME_STR = 100, 3077 3078 /** 3079 * Indicates the algorithm name of the mask generation function. It is used in RSA signing and verifying process. 3080 * 3081 * @syscap SystemCapability.Security.CryptoFramework 3082 * @since 10 3083 */ 3084 /** 3085 * Indicates the algorithm name of the mask generation function. It is used in RSA signing and verifying process. 3086 * 3087 * @syscap SystemCapability.Security.CryptoFramework 3088 * @crossplatform 3089 * @since 11 3090 */ 3091 /** 3092 * Indicates the algorithm name of the mask generation function. It is used in RSA signing and verifying process. 3093 * 3094 * @syscap SystemCapability.Security.CryptoFramework.Signature 3095 * @crossplatform 3096 * @atomicservice 3097 * @since 12 3098 */ 3099 PSS_MGF_NAME_STR = 101, 3100 3101 /** 3102 * Indicates the message digest parameter for the MGF1 mask generation function. 3103 * It is used in RSA signing and verifying process. 3104 * 3105 * @syscap SystemCapability.Security.CryptoFramework 3106 * @since 10 3107 */ 3108 /** 3109 * Indicates the message digest parameter for the MGF1 mask generation function. 3110 * It is used in RSA signing and verifying process. 3111 * 3112 * @syscap SystemCapability.Security.CryptoFramework 3113 * @crossplatform 3114 * @since 11 3115 */ 3116 /** 3117 * Indicates the message digest parameter for the MGF1 mask generation function. 3118 * It is used in RSA signing and verifying process. 3119 * 3120 * @syscap SystemCapability.Security.CryptoFramework.Signature 3121 * @crossplatform 3122 * @atomicservice 3123 * @since 12 3124 */ 3125 PSS_MGF1_MD_STR = 102, 3126 3127 /** 3128 * Indicates the salt length in bits. It is used in RSA signing and verifying process. 3129 * 3130 * @syscap SystemCapability.Security.CryptoFramework 3131 * @since 10 3132 */ 3133 /** 3134 * Indicates the salt length in bits. It is used in RSA signing and verifying process. 3135 * 3136 * @syscap SystemCapability.Security.CryptoFramework 3137 * @crossplatform 3138 * @since 11 3139 */ 3140 /** 3141 * Indicates the salt length in bits. It is used in RSA signing and verifying process. 3142 * 3143 * @syscap SystemCapability.Security.CryptoFramework.Signature 3144 * @crossplatform 3145 * @atomicservice 3146 * @since 12 3147 */ 3148 PSS_SALT_LEN_NUM = 103, 3149 3150 /** 3151 * Indicates the value for the trailer field. It is used in RSA signing and verifying process. 3152 * 3153 * @syscap SystemCapability.Security.CryptoFramework 3154 * @since 10 3155 */ 3156 /** 3157 * Indicates the value for the trailer field. It is used in RSA signing and verifying process. 3158 * 3159 * @syscap SystemCapability.Security.CryptoFramework 3160 * @crossplatform 3161 * @since 11 3162 */ 3163 /** 3164 * Indicates the value for the trailer field. It is used in RSA signing and verifying process. 3165 * 3166 * @syscap SystemCapability.Security.CryptoFramework.Signature 3167 * @crossplatform 3168 * @atomicservice 3169 * @since 12 3170 */ 3171 PSS_TRAILER_FIELD_NUM = 104, 3172 3173 /** 3174 * Indicates the value for user id. It is used in SM2 signing and verifying process. 3175 * 3176 * @syscap SystemCapability.Security.CryptoFramework 3177 * @crossplatform 3178 * @since 11 3179 */ 3180 /** 3181 * Indicates the value for user id. It is used in SM2 signing and verifying process. 3182 * 3183 * @syscap SystemCapability.Security.CryptoFramework.Signature 3184 * @crossplatform 3185 * @atomicservice 3186 * @since 12 3187 */ 3188 SM2_USER_ID_UINT8ARR = 105 3189 } 3190 3191 /** 3192 * Provides the Cipher type, which is used for encryption and decryption operations. 3193 * 3194 * @typedef Cipher 3195 * @syscap SystemCapability.Security.CryptoFramework 3196 * @since 9 3197 */ 3198 /** 3199 * Provides the Cipher type, which is used for encryption and decryption operations. 3200 * 3201 * @typedef Cipher 3202 * @syscap SystemCapability.Security.CryptoFramework 3203 * @crossplatform 3204 * @since 11 3205 */ 3206 /** 3207 * Provides the Cipher type, which is used for encryption and decryption operations. 3208 * 3209 * @typedef Cipher 3210 * @syscap SystemCapability.Security.CryptoFramework.Cipher 3211 * @crossplatform 3212 * @atomicservice 3213 * @since 12 3214 */ 3215 interface Cipher { 3216 /** 3217 * Init the crypto operation with the given crypto mode, key and parameters. 3218 * 3219 * @param { CryptoMode } opMode - indicates the crypto mode is encryption or decryption. 3220 * @param { Key } key - indicates the symmetric key or the asymmetric key. 3221 * @param { ParamsSpec } params - indicates the algorithm parameters such as IV. 3222 * @param { AsyncCallback<void> } callback - the callback of the init function. 3223 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3224 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3225 * @throws { BusinessError } 17620001 - memory operation failed. 3226 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3227 * @throws { BusinessError } 17630001 - crypto operation error. 3228 * @syscap SystemCapability.Security.CryptoFramework 3229 * @since 9 3230 */ 3231 /** 3232 * Init the crypto operation with the given crypto mode, key and parameters. 3233 * 3234 * @param { CryptoMode } opMode - indicates the crypto mode is encryption or decryption. 3235 * @param { Key } key - indicates the symmetric key or the asymmetric key. 3236 * @param { ParamsSpec } params - indicates the algorithm parameters such as IV. 3237 * @param { AsyncCallback<void> } callback - the callback of the init function. 3238 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3239 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3240 * @throws { BusinessError } 17620001 - memory operation failed. 3241 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3242 * @throws { BusinessError } 17630001 - crypto operation error. 3243 * @syscap SystemCapability.Security.CryptoFramework 3244 * @crossplatform 3245 * @since 11 3246 */ 3247 /** 3248 * Init the crypto operation with the given crypto mode, key and parameters. 3249 * init, update, and doFinal must be used together. init and doFinal are mandatory, and update is optional. 3250 * 3251 * @param { CryptoMode } opMode - indicates the crypto mode is encryption or decryption. 3252 * @param { Key } key - indicates the symmetric key or the asymmetric key. 3253 * @param { ParamsSpec } params - indicates the algorithm parameters such as IV. 3254 * @param { AsyncCallback<void> } callback - the callback of the init function. 3255 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3256 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3257 * @throws { BusinessError } 17620001 - memory operation failed. 3258 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3259 * @throws { BusinessError } 17630001 - crypto operation error. 3260 * @syscap SystemCapability.Security.CryptoFramework.Cipher 3261 * @crossplatform 3262 * @atomicservice 3263 * @since 12 3264 */ 3265 init(opMode: CryptoMode, key: Key, params: ParamsSpec, callback: AsyncCallback<void>): void; 3266 3267 /** 3268 * Init the crypto operation with the given crypto mode, key and parameters. 3269 * 3270 * @param { CryptoMode } opMode - indicates the crypto mode is encryption or decryption. 3271 * @param { Key } key - indicates the symmetric key or the asymmetric key. 3272 * @param { ParamsSpec | null } params - indicates the algorithm parameters such as IV. 3273 * @param { AsyncCallback<void> } callback - the callback of the init function. 3274 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3275 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3276 * @throws { BusinessError } 17620001 - memory operation failed. 3277 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3278 * @throws { BusinessError } 17630001 - crypto operation error. 3279 * @syscap SystemCapability.Security.CryptoFramework 3280 * @since 10 3281 */ 3282 /** 3283 * Init the crypto operation with the given crypto mode, key and parameters. 3284 * 3285 * @param { CryptoMode } opMode - indicates the crypto mode is encryption or decryption. 3286 * @param { Key } key - indicates the symmetric key or the asymmetric key. 3287 * @param { ParamsSpec | null } params - indicates the algorithm parameters such as IV. 3288 * @param { AsyncCallback<void> } callback - the callback of the init function. 3289 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3290 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3291 * @throws { BusinessError } 17620001 - memory operation failed. 3292 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3293 * @throws { BusinessError } 17630001 - crypto operation error. 3294 * @syscap SystemCapability.Security.CryptoFramework 3295 * @crossplatform 3296 * @since 11 3297 */ 3298 /** 3299 * Init the crypto operation with the given crypto mode, key and parameters. 3300 * init, update, and doFinal must be used together. init and doFinal are mandatory, and update is optional. 3301 * 3302 * @param { CryptoMode } opMode - indicates the crypto mode is encryption or decryption. 3303 * @param { Key } key - indicates the symmetric key or the asymmetric key. 3304 * @param { ParamsSpec | null } params - indicates the algorithm parameters such as IV. 3305 * @param { AsyncCallback<void> } callback - the callback of the init function. 3306 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3307 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3308 * @throws { BusinessError } 17620001 - memory operation failed. 3309 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3310 * @throws { BusinessError } 17630001 - crypto operation error. 3311 * @syscap SystemCapability.Security.CryptoFramework.Cipher 3312 * @crossplatform 3313 * @atomicservice 3314 * @since 12 3315 */ 3316 init(opMode: CryptoMode, key: Key, params: ParamsSpec | null, callback: AsyncCallback<void>): void; 3317 3318 /** 3319 * Init the crypto operation with the given crypto mode, key and parameters. 3320 * 3321 * @param { CryptoMode } opMode - indicates the crypto mode is encryption or decryption. 3322 * @param { Key } key - indicates the symmetric key or the asymmetric key. 3323 * @param { ParamsSpec } params - indicates the algorithm parameters such as IV. 3324 * @returns { Promise<void> } the promise returned by the function. 3325 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3326 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3327 * @throws { BusinessError } 17620001 - memory operation failed. 3328 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3329 * @throws { BusinessError } 17630001 - crypto operation error. 3330 * @syscap SystemCapability.Security.CryptoFramework 3331 * @since 9 3332 */ 3333 /** 3334 * Init the crypto operation with the given crypto mode, key and parameters. 3335 * 3336 * @param { CryptoMode } opMode - indicates the crypto mode is encryption or decryption. 3337 * @param { Key } key - indicates the symmetric key or the asymmetric key. 3338 * @param { ParamsSpec } params - indicates the algorithm parameters such as IV. 3339 * @returns { Promise<void> } the promise returned by the function. 3340 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3341 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3342 * @throws { BusinessError } 17620001 - memory operation failed. 3343 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3344 * @throws { BusinessError } 17630001 - crypto operation error. 3345 * @syscap SystemCapability.Security.CryptoFramework 3346 * @crossplatform 3347 * @since 11 3348 */ 3349 /** 3350 * Init the crypto operation with the given crypto mode, key and parameters. 3351 * init, update, and doFinal must be used together. init and doFinal are mandatory, and update is optional. 3352 * 3353 * @param { CryptoMode } opMode - indicates the crypto mode is encryption or decryption. 3354 * @param { Key } key - indicates the symmetric key or the asymmetric key. 3355 * @param { ParamsSpec } params - indicates the algorithm parameters such as IV. 3356 * @returns { Promise<void> } the promise returned by the function. 3357 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3358 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3359 * @throws { BusinessError } 17620001 - memory operation failed. 3360 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3361 * @throws { BusinessError } 17630001 - crypto operation error. 3362 * @syscap SystemCapability.Security.CryptoFramework.Cipher 3363 * @crossplatform 3364 * @atomicservice 3365 * @since 12 3366 */ 3367 init(opMode: CryptoMode, key: Key, params: ParamsSpec): Promise<void>; 3368 3369 /** 3370 * Init the crypto operation with the given crypto mode, key and parameters. 3371 * 3372 * @param { CryptoMode } opMode - indicates the crypto mode is encryption or decryption. 3373 * @param { Key } key - indicates the symmetric key or the asymmetric key. 3374 * @param { ParamsSpec | null } params - indicates the algorithm parameters such as IV. 3375 * @returns { Promise<void> } the promise returned by the function. 3376 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3377 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3378 * @throws { BusinessError } 17620001 - memory operation failed. 3379 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3380 * @throws { BusinessError } 17630001 - crypto operation error. 3381 * @syscap SystemCapability.Security.CryptoFramework 3382 * @since 10 3383 */ 3384 /** 3385 * Init the crypto operation with the given crypto mode, key and parameters. 3386 * 3387 * @param { CryptoMode } opMode - indicates the crypto mode is encryption or decryption. 3388 * @param { Key } key - indicates the symmetric key or the asymmetric key. 3389 * @param { ParamsSpec | null } params - indicates the algorithm parameters such as IV. 3390 * @returns { Promise<void> } the promise returned by the function. 3391 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3392 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3393 * @throws { BusinessError } 17620001 - memory operation failed. 3394 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3395 * @throws { BusinessError } 17630001 - crypto operation error. 3396 * @syscap SystemCapability.Security.CryptoFramework 3397 * @crossplatform 3398 * @since 11 3399 */ 3400 /** 3401 * Init the crypto operation with the given crypto mode, key and parameters. 3402 * init, update, and doFinal must be used together. init and doFinal are mandatory, and update is optional. 3403 * 3404 * @param { CryptoMode } opMode - indicates the crypto mode is encryption or decryption. 3405 * @param { Key } key - indicates the symmetric key or the asymmetric key. 3406 * @param { ParamsSpec | null } params - indicates the algorithm parameters such as IV. 3407 * @returns { Promise<void> } the promise returned by the function. 3408 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3409 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3410 * @throws { BusinessError } 17620001 - memory operation failed. 3411 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3412 * @throws { BusinessError } 17630001 - crypto operation error. 3413 * @syscap SystemCapability.Security.CryptoFramework.Cipher 3414 * @crossplatform 3415 * @atomicservice 3416 * @since 12 3417 */ 3418 init(opMode: CryptoMode, key: Key, params: ParamsSpec | null): Promise<void>; 3419 3420 /** 3421 * Init the crypto operation with the given crypto mode, key and parameters. 3422 * init, update, and doFinal must be used together. init and doFinal are mandatory, and update is optional. 3423 * 3424 * @param { CryptoMode } opMode - indicates the crypto mode is encryption or decryption. 3425 * @param { Key } key - indicates the symmetric key or the asymmetric key. 3426 * @param { ParamsSpec | null } params - indicates the algorithm parameters such as IV. 3427 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3428 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3429 * @throws { BusinessError } 17620001 - memory operation failed. 3430 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3431 * @throws { BusinessError } 17630001 - crypto operation error. 3432 * @syscap SystemCapability.Security.CryptoFramework.Cipher 3433 * @crossplatform 3434 * @atomicservice 3435 * @since 12 3436 */ 3437 initSync(opMode: CryptoMode, key: Key, params: ParamsSpec | null): void; 3438 3439 /** 3440 * Update the crypto operation with the input data, and feed back the encrypted or decrypted data 3441 * this time. RSA is not supported in this function. 3442 * 3443 * @param { DataBlob } data - indicates the data to be encrypted or decrypted. 3444 * @param { AsyncCallback<DataBlob> } callback - the callback of the update function. 3445 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3446 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3447 * @throws { BusinessError } 17620001 - memory operation failed. 3448 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3449 * @throws { BusinessError } 17630001 - crypto operation error. 3450 * @syscap SystemCapability.Security.CryptoFramework 3451 * @since 9 3452 */ 3453 /** 3454 * Update the crypto operation with the input data, and feed back the encrypted or decrypted data 3455 * this time. RSA is not supported in this function. 3456 * 3457 * @param { DataBlob } data - indicates the data to be encrypted or decrypted. 3458 * @param { AsyncCallback<DataBlob> } callback - the callback of the update function. 3459 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3460 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3461 * @throws { BusinessError } 17620001 - memory operation failed. 3462 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3463 * @throws { BusinessError } 17630001 - crypto operation error. 3464 * @syscap SystemCapability.Security.CryptoFramework 3465 * @crossplatform 3466 * @since 11 3467 */ 3468 /** 3469 * Update the crypto operation with the input data, and feed back the encrypted or decrypted data 3470 * this time. RSA is not supported in this function. 3471 * 3472 * @param { DataBlob } data - indicates the data to be encrypted or decrypted. 3473 * @param { AsyncCallback<DataBlob> } callback - the callback of the update function. 3474 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3475 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3476 * @throws { BusinessError } 17620001 - memory operation failed. 3477 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3478 * @throws { BusinessError } 17630001 - crypto operation error. 3479 * @syscap SystemCapability.Security.CryptoFramework.Cipher 3480 * @crossplatform 3481 * @atomicservice 3482 * @since 12 3483 */ 3484 update(data: DataBlob, callback: AsyncCallback<DataBlob>): void; 3485 3486 /** 3487 * Update the crypto operation with the input data, and feed back the encrypted or decrypted data 3488 * this time. RSA is not supported in this function. 3489 * 3490 * @param { DataBlob } data - indicates the data to be encrypted or decrypted. 3491 * @returns { Promise<DataBlob> } the promise returned by the function. 3492 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3493 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3494 * @throws { BusinessError } 17620001 - memory operation failed. 3495 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3496 * @throws { BusinessError } 17630001 - crypto operation error. 3497 * @syscap SystemCapability.Security.CryptoFramework 3498 * @since 9 3499 */ 3500 /** 3501 * Update the crypto operation with the input data, and feed back the encrypted or decrypted data 3502 * this time. RSA is not supported in this function. 3503 * 3504 * @param { DataBlob } data - indicates the data to be encrypted or decrypted. 3505 * @returns { Promise<DataBlob> } the promise returned by the function. 3506 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3507 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3508 * @throws { BusinessError } 17620001 - memory operation failed. 3509 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3510 * @throws { BusinessError } 17630001 - crypto operation error. 3511 * @syscap SystemCapability.Security.CryptoFramework 3512 * @crossplatform 3513 * @since 11 3514 */ 3515 /** 3516 * Update the crypto operation with the input data, and feed back the encrypted or decrypted data 3517 * this time. RSA is not supported in this function. 3518 * 3519 * @param { DataBlob } data - indicates the data to be encrypted or decrypted. 3520 * @returns { Promise<DataBlob> } the promise returned by the function. 3521 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3522 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3523 * @throws { BusinessError } 17620001 - memory operation failed. 3524 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3525 * @throws { BusinessError } 17630001 - crypto operation error. 3526 * @syscap SystemCapability.Security.CryptoFramework.Cipher 3527 * @crossplatform 3528 * @atomicservice 3529 * @since 12 3530 */ 3531 update(data: DataBlob): Promise<DataBlob>; 3532 3533 /** 3534 * Update the crypto operation with the input data, and feed back the encrypted or decrypted data 3535 * this time. RSA is not supported in this function. 3536 * 3537 * @param { DataBlob } data - indicates the data to be encrypted or decrypted. 3538 * @returns { DataBlob } cipherText when encrypted or plainText when decrypted. 3539 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3540 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3541 * @throws { BusinessError } 17620001 - memory operation failed. 3542 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3543 * @throws { BusinessError } 17630001 - crypto operation error. 3544 * @syscap SystemCapability.Security.CryptoFramework.Cipher 3545 * @crossplatform 3546 * @atomicservice 3547 * @since 12 3548 */ 3549 updateSync(data: DataBlob): DataBlob; 3550 3551 /** 3552 * Finish the crypto operation, encrypt or decrypt the input data, and then feed back the output data. 3553 * Data cannot be updated after the crypto operation is finished. 3554 * 3555 * @param { DataBlob } data - indicates the data to be finally encrypted or decrypted. 3556 * @param { AsyncCallback<DataBlob> } callback - the callback of the doFinal function. 3557 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3558 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3559 * @throws { BusinessError } 17620001 - memory operation failed. 3560 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3561 * @throws { BusinessError } 17630001 - crypto operation error. 3562 * @syscap SystemCapability.Security.CryptoFramework 3563 * @since 9 3564 */ 3565 /** 3566 * Finish the crypto operation, encrypt or decrypt the input data, and then feed back the output data. 3567 * Data cannot be updated after the crypto operation is finished. 3568 * 3569 * @param { DataBlob } data - indicates the data to be finally encrypted or decrypted. 3570 * @param { AsyncCallback<DataBlob> } callback - the callback of the doFinal function. 3571 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3572 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3573 * @throws { BusinessError } 17620001 - memory operation failed. 3574 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3575 * @throws { BusinessError } 17630001 - crypto operation error. 3576 * @syscap SystemCapability.Security.CryptoFramework 3577 * @crossplatform 3578 * @since 11 3579 */ 3580 /** 3581 * Finish the crypto operation, encrypt or decrypt the input data, and then feed back the output data. 3582 * Data cannot be updated after the crypto operation is finished. 3583 * 3584 * @param { DataBlob } data - indicates the data to be finally encrypted or decrypted. 3585 * @param { AsyncCallback<DataBlob> } callback - the callback of the doFinal function. 3586 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3587 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3588 * @throws { BusinessError } 17620001 - memory operation failed. 3589 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3590 * @throws { BusinessError } 17630001 - crypto operation error. 3591 * @syscap SystemCapability.Security.CryptoFramework.Cipher 3592 * @crossplatform 3593 * @atomicservice 3594 * @since 12 3595 */ 3596 doFinal(data: DataBlob, callback: AsyncCallback<DataBlob>): void; 3597 3598 /** 3599 * Finish the crypto operation, encrypt or decrypt the input data, and then feed back the output data. 3600 * Data cannot be updated after the crypto operation is finished. 3601 * 3602 * @param { DataBlob | null } data - indicates the data to be finally encrypted or decrypted. 3603 * @param { AsyncCallback<DataBlob> } callback - the callback of the doFinal function. 3604 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3605 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3606 * @throws { BusinessError } 17620001 - memory operation failed. 3607 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3608 * @throws { BusinessError } 17630001 - crypto operation error. 3609 * @syscap SystemCapability.Security.CryptoFramework 3610 * @since 10 3611 */ 3612 /** 3613 * Finish the crypto operation, encrypt or decrypt the input data, and then feed back the output data. 3614 * Data cannot be updated after the crypto operation is finished. 3615 * 3616 * @param { DataBlob | null } data - indicates the data to be finally encrypted or decrypted. 3617 * @param { AsyncCallback<DataBlob> } callback - the callback of the doFinal function. 3618 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3619 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3620 * @throws { BusinessError } 17620001 - memory operation failed. 3621 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3622 * @throws { BusinessError } 17630001 - crypto operation error. 3623 * @syscap SystemCapability.Security.CryptoFramework 3624 * @crossplatform 3625 * @since 11 3626 */ 3627 /** 3628 * Finish the crypto operation, encrypt or decrypt the input data, and then feed back the output data. 3629 * Data cannot be updated after the crypto operation is finished. 3630 * 3631 * @param { DataBlob | null } data - indicates the data to be finally encrypted or decrypted. 3632 * @param { AsyncCallback<DataBlob> } callback - the callback of the doFinal function. 3633 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3634 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3635 * @throws { BusinessError } 17620001 - memory operation failed. 3636 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3637 * @throws { BusinessError } 17630001 - crypto operation error. 3638 * @syscap SystemCapability.Security.CryptoFramework.Cipher 3639 * @crossplatform 3640 * @atomicservice 3641 * @since 12 3642 */ 3643 doFinal(data: DataBlob | null, callback: AsyncCallback<DataBlob>): void; 3644 3645 /** 3646 * Finish the crypto operation, encrypt or decrypt the input data, and then feed back the output data. 3647 * Data cannot be updated after the crypto operation is finished. 3648 * 3649 * @param { DataBlob } data - indicates the data to be finally encrypted or decrypted. 3650 * @returns { Promise<DataBlob> } the promise returned by the function. 3651 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3652 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3653 * @throws { BusinessError } 17620001 - memory operation failed. 3654 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3655 * @throws { BusinessError } 17630001 - crypto operation error. 3656 * @syscap SystemCapability.Security.CryptoFramework 3657 * @since 9 3658 */ 3659 /** 3660 * Finish the crypto operation, encrypt or decrypt the input data, and then feed back the output data. 3661 * Data cannot be updated after the crypto operation is finished. 3662 * 3663 * @param { DataBlob } data - indicates the data to be finally encrypted or decrypted. 3664 * @returns { Promise<DataBlob> } the promise returned by the function. 3665 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3666 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3667 * @throws { BusinessError } 17620001 - memory operation failed. 3668 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3669 * @throws { BusinessError } 17630001 - crypto operation error. 3670 * @syscap SystemCapability.Security.CryptoFramework 3671 * @crossplatform 3672 * @since 11 3673 */ 3674 /** 3675 * Finish the crypto operation, encrypt or decrypt the input data, and then feed back the output data. 3676 * Data cannot be updated after the crypto operation is finished. 3677 * 3678 * @param { DataBlob } data - indicates the data to be finally encrypted or decrypted. 3679 * @returns { Promise<DataBlob> } the promise returned by the function. 3680 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3681 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3682 * @throws { BusinessError } 17620001 - memory operation failed. 3683 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3684 * @throws { BusinessError } 17630001 - crypto operation error. 3685 * @syscap SystemCapability.Security.CryptoFramework.Cipher 3686 * @crossplatform 3687 * @atomicservice 3688 * @since 12 3689 */ 3690 doFinal(data: DataBlob): Promise<DataBlob>; 3691 3692 /** 3693 * Finish the crypto operation, encrypt or decrypt the input data, and then feed back the output data. 3694 * Data cannot be updated after the crypto operation is finished. 3695 * 3696 * @param { DataBlob | null } data - indicates the data to be finally encrypted or decrypted. 3697 * @returns { Promise<DataBlob> } the promise returned by the function. 3698 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3699 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3700 * @throws { BusinessError } 17620001 - memory operation failed. 3701 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3702 * @throws { BusinessError } 17630001 - crypto operation error. 3703 * @syscap SystemCapability.Security.CryptoFramework 3704 * @since 10 3705 */ 3706 /** 3707 * Finish the crypto operation, encrypt or decrypt the input data, and then feed back the output data. 3708 * Data cannot be updated after the crypto operation is finished. 3709 * 3710 * @param { DataBlob | null } data - indicates the data to be finally encrypted or decrypted. 3711 * @returns { Promise<DataBlob> } the promise returned by the function. 3712 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3713 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3714 * @throws { BusinessError } 17620001 - memory operation failed. 3715 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3716 * @throws { BusinessError } 17630001 - crypto operation error. 3717 * @syscap SystemCapability.Security.CryptoFramework 3718 * @crossplatform 3719 * @since 11 3720 */ 3721 /** 3722 * Finish the crypto operation, encrypt or decrypt the input data, and then feed back the output data. 3723 * Data cannot be updated after the crypto operation is finished. 3724 * 3725 * @param { DataBlob | null } data - indicates the data to be finally encrypted or decrypted. 3726 * @returns { Promise<DataBlob> } the promise returned by the function. 3727 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3728 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3729 * @throws { BusinessError } 17620001 - memory operation failed. 3730 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3731 * @throws { BusinessError } 17630001 - crypto operation error. 3732 * @syscap SystemCapability.Security.CryptoFramework.Cipher 3733 * @crossplatform 3734 * @atomicservice 3735 * @since 12 3736 */ 3737 doFinal(data: DataBlob | null): Promise<DataBlob>; 3738 3739 /** 3740 * Finish the crypto operation, encrypt or decrypt the input data, and then feed back the output data. 3741 * Data cannot be updated after the crypto operation is finished. 3742 * 3743 * @param { DataBlob | null } data - indicates the data to be finally encrypted or decrypted. 3744 * @returns { DataBlob } cipherText when encrypted or plainText when decrypted. 3745 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3746 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3747 * @throws { BusinessError } 17620001 - memory operation failed. 3748 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3749 * @throws { BusinessError } 17630001 - crypto operation error. 3750 * @syscap SystemCapability.Security.CryptoFramework.Cipher 3751 * @crossplatform 3752 * @atomicservice 3753 * @since 12 3754 */ 3755 doFinalSync(data: DataBlob | null): DataBlob; 3756 3757 /** 3758 * Set the specified parameter to the cipher object. 3759 * Currently, only the OAEP_MGF1_PSRC_UINT8ARR parameter in RSA is supported. 3760 * 3761 * @param { CipherSpecItem } itemType - indicates the specified parameter type. 3762 * @param { Uint8Array } itemValue - the value of the specified parameter. 3763 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3764 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3765 * @throws { BusinessError } 801 - this operation is not supported. 3766 * @throws { BusinessError } 17620001 - memory operation failed. 3767 * @throws { BusinessError } 17630001 - crypto operation error. 3768 * @syscap SystemCapability.Security.CryptoFramework 3769 * @since 10 3770 */ 3771 /** 3772 * Set the specified parameter to the cipher object. 3773 * Currently, only the OAEP_MGF1_PSRC_UINT8ARR parameter in RSA is supported. 3774 * 3775 * @param { CipherSpecItem } itemType - indicates the specified parameter type. 3776 * @param { Uint8Array } itemValue - the value of the specified parameter. 3777 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3778 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3779 * @throws { BusinessError } 801 - this operation is not supported. 3780 * @throws { BusinessError } 17620001 - memory operation failed. 3781 * @throws { BusinessError } 17630001 - crypto operation error. 3782 * @syscap SystemCapability.Security.CryptoFramework 3783 * @crossplatform 3784 * @since 11 3785 */ 3786 /** 3787 * Set the specified parameter to the cipher object. 3788 * Currently, only the OAEP_MGF1_PSRC_UINT8ARR parameter in RSA is supported. 3789 * 3790 * @param { CipherSpecItem } itemType - indicates the specified parameter type. 3791 * @param { Uint8Array } itemValue - the value of the specified parameter. 3792 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3793 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3794 * @throws { BusinessError } 801 - this operation is not supported. 3795 * @throws { BusinessError } 17620001 - memory operation failed. 3796 * @throws { BusinessError } 17630001 - crypto operation error. 3797 * @syscap SystemCapability.Security.CryptoFramework.Cipher 3798 * @crossplatform 3799 * @atomicservice 3800 * @since 12 3801 */ 3802 setCipherSpec(itemType: CipherSpecItem, itemValue: Uint8Array): void; 3803 3804 /** 3805 * Get the specified parameter from the cipher object. 3806 * Currently, only OAEP parameters in RSA is supported. 3807 * 3808 * @param { CipherSpecItem } itemType - indicates the specified parameter type. 3809 * @returns { string | Uint8Array } the value of the specified parameter. 3810 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3811 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3812 * @throws { BusinessError } 801 - this operation is not supported. 3813 * @throws { BusinessError } 17620001 - memory operation failed. 3814 * @throws { BusinessError } 17630001 - crypto operation error. 3815 * @syscap SystemCapability.Security.CryptoFramework 3816 * @since 10 3817 */ 3818 /** 3819 * Get the specified parameter from the cipher object. 3820 * Currently, only OAEP parameters in RSA is supported. 3821 * 3822 * @param { CipherSpecItem } itemType - indicates the specified parameter type. 3823 * @returns { string | Uint8Array } the value of the specified parameter. 3824 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3825 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3826 * @throws { BusinessError } 801 - this operation is not supported. 3827 * @throws { BusinessError } 17620001 - memory operation failed. 3828 * @throws { BusinessError } 17630001 - crypto operation error. 3829 * @syscap SystemCapability.Security.CryptoFramework 3830 * @crossplatform 3831 * @since 11 3832 */ 3833 /** 3834 * Get the specified parameter from the cipher object. 3835 * Currently, only OAEP parameters in RSA is supported. 3836 * 3837 * @param { CipherSpecItem } itemType - indicates the specified parameter type. 3838 * @returns { string | Uint8Array } the value of the specified parameter. 3839 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3840 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3841 * @throws { BusinessError } 801 - this operation is not supported. 3842 * @throws { BusinessError } 17620001 - memory operation failed. 3843 * @throws { BusinessError } 17630001 - crypto operation error. 3844 * @syscap SystemCapability.Security.CryptoFramework.Cipher 3845 * @crossplatform 3846 * @atomicservice 3847 * @since 12 3848 */ 3849 getCipherSpec(itemType: CipherSpecItem): string | Uint8Array; 3850 3851 /** 3852 * Indicates the algorithm name of the cipher object. 3853 * 3854 * @type { string } 3855 * @readonly 3856 * @syscap SystemCapability.Security.CryptoFramework 3857 * @since 9 3858 */ 3859 /** 3860 * Indicates the algorithm name of the cipher object. 3861 * 3862 * @type { string } 3863 * @readonly 3864 * @syscap SystemCapability.Security.CryptoFramework 3865 * @crossplatform 3866 * @since 11 3867 */ 3868 /** 3869 * Indicates the algorithm name of the cipher object. 3870 * 3871 * @type { string } 3872 * @readonly 3873 * @syscap SystemCapability.Security.CryptoFramework.Cipher 3874 * @crossplatform 3875 * @atomicservice 3876 * @since 12 3877 */ 3878 readonly algName: string; 3879 } 3880 3881 /** 3882 * Create a cipher object for encryption and decryption operations according to the given specifications. 3883 * Two different Cipher objects should be created when using RSA encryption and decryption, 3884 * even with the same specifications. 3885 * 3886 * @param { string } transformation - indicates the description to be transformed to cipher specifications. 3887 * @returns { Cipher } the cipher object returned by the function. 3888 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3889 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3890 * @throws { BusinessError } 801 - this operation is not supported. 3891 * @throws { BusinessError } 17620001 - memory operation failed. 3892 * @syscap SystemCapability.Security.CryptoFramework 3893 * @since 9 3894 */ 3895 /** 3896 * Create a cipher object for encryption and decryption operations according to the given specifications. 3897 * Two different Cipher objects should be created when using RSA encryption and decryption, 3898 * even with the same specifications. 3899 * 3900 * @param { string } transformation - indicates the description to be transformed to cipher specifications. 3901 * @returns { Cipher } the cipher object returned by the function. 3902 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3903 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3904 * @throws { BusinessError } 801 - this operation is not supported. 3905 * @throws { BusinessError } 17620001 - memory operation failed. 3906 * @syscap SystemCapability.Security.CryptoFramework 3907 * @crossplatform 3908 * @since 11 3909 */ 3910 /** 3911 * Create a cipher object for encryption and decryption operations according to the given specifications. 3912 * Two different Cipher objects should be created when using RSA encryption and decryption, 3913 * even with the same specifications. 3914 * 3915 * @param { string } transformation - indicates the description to be transformed to cipher specifications. 3916 * Multiple parameters need to be concatenated by "|". 3917 * @returns { Cipher } the cipher object returned by the function. 3918 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3919 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3920 * @throws { BusinessError } 801 - this operation is not supported. 3921 * @throws { BusinessError } 17620001 - memory operation failed. 3922 * @syscap SystemCapability.Security.CryptoFramework.Cipher 3923 * @crossplatform 3924 * @atomicservice 3925 * @since 12 3926 */ 3927 function createCipher(transformation: string): Cipher; 3928 3929 /** 3930 * Provides the Sign type, which is used for generating signatures. 3931 * 3932 * @typedef Sign 3933 * @syscap SystemCapability.Security.CryptoFramework 3934 * @since 9 3935 */ 3936 /** 3937 * Provides the Sign type, which is used for generating signatures. 3938 * 3939 * @typedef Sign 3940 * @syscap SystemCapability.Security.CryptoFramework 3941 * @crossplatform 3942 * @since 11 3943 */ 3944 /** 3945 * Provides the Sign type, which is used for generating signatures. 3946 * Before using any API of the Sign class, you must create a Sign instance by using createSign. 3947 * 3948 * @typedef Sign 3949 * @syscap SystemCapability.Security.CryptoFramework.Signature 3950 * @crossplatform 3951 * @atomicservice 3952 * @since 12 3953 */ 3954 interface Sign { 3955 /** 3956 * Used to init environment. 3957 * 3958 * @param { PriKey } priKey - the private key. 3959 * @param { AsyncCallback<void> } callback - the call back function return nothing. 3960 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3961 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3962 * @throws { BusinessError } 17620001 - memory operation failed. 3963 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3964 * @throws { BusinessError } 17630001 - crypto operation error. 3965 * @syscap SystemCapability.Security.CryptoFramework 3966 * @since 9 3967 */ 3968 /** 3969 * Used to init environment. 3970 * 3971 * @param { PriKey } priKey - the private key. 3972 * @param { AsyncCallback<void> } callback - the call back function return nothing. 3973 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3974 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3975 * @throws { BusinessError } 17620001 - memory operation failed. 3976 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3977 * @throws { BusinessError } 17630001 - crypto operation error. 3978 * @syscap SystemCapability.Security.CryptoFramework 3979 * @crossplatform 3980 * @since 11 3981 */ 3982 /** 3983 * Initializes the Sign instance with a private key. 3984 * init, update, and sign must be used together. init and sign are mandatory, and update is optional. 3985 * 3986 * @param { PriKey } priKey - the private key. 3987 * @param { AsyncCallback<void> } callback - the call back function return nothing. 3988 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 3989 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 3990 * @throws { BusinessError } 17620001 - memory operation failed. 3991 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 3992 * @throws { BusinessError } 17630001 - crypto operation error. 3993 * @syscap SystemCapability.Security.CryptoFramework.Signature 3994 * @crossplatform 3995 * @atomicservice 3996 * @since 12 3997 */ 3998 init(priKey: PriKey, callback: AsyncCallback<void>): void; 3999 4000 /** 4001 * Used to init environment. 4002 * 4003 * @param { PriKey } priKey - the private key. 4004 * @returns { Promise<void> } return nothing. 4005 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4006 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4007 * @throws { BusinessError } 17620001 - memory operation failed. 4008 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4009 * @throws { BusinessError } 17630001 - crypto operation error. 4010 * @syscap SystemCapability.Security.CryptoFramework 4011 * @since 9 4012 */ 4013 /** 4014 * Used to init environment. 4015 * 4016 * @param { PriKey } priKey - the private key. 4017 * @returns { Promise<void> } return nothing. 4018 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4019 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4020 * @throws { BusinessError } 17620001 - memory operation failed. 4021 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4022 * @throws { BusinessError } 17630001 - crypto operation error. 4023 * @syscap SystemCapability.Security.CryptoFramework 4024 * @crossplatform 4025 * @since 11 4026 */ 4027 /** 4028 * Initializes the Sign instance with a private key. 4029 * init, update, and sign must be used together. init and sign are mandatory, and update is optional. 4030 * 4031 * @param { PriKey } priKey - the private key. 4032 * @returns { Promise<void> } return nothing. 4033 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4034 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4035 * @throws { BusinessError } 17620001 - memory operation failed. 4036 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4037 * @throws { BusinessError } 17630001 - crypto operation error. 4038 * @syscap SystemCapability.Security.CryptoFramework.Signature 4039 * @crossplatform 4040 * @atomicservice 4041 * @since 12 4042 */ 4043 init(priKey: PriKey): Promise<void>; 4044 4045 /** 4046 * Initializes the Sign instance with a private key. 4047 * init, update, and sign must be used together. init and sign are mandatory, and update is optional. 4048 * 4049 * @param { PriKey } priKey - the private key. 4050 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4051 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4052 * @throws { BusinessError } 17620001 - memory operation failed. 4053 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4054 * @throws { BusinessError } 17630001 - crypto operation error. 4055 * @syscap SystemCapability.Security.CryptoFramework.Signature 4056 * @crossplatform 4057 * @atomicservice 4058 * @since 12 4059 */ 4060 initSync(priKey: PriKey): void; 4061 4062 /** 4063 * Used to append the message need to be signed. 4064 * 4065 * @param { DataBlob } data - the data need to be signed. 4066 * @param { AsyncCallback<void> } callback - the call back function return nothing. 4067 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4068 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4069 * @throws { BusinessError } 17620001 - memory operation failed. 4070 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4071 * @throws { BusinessError } 17630001 - crypto operation error. 4072 * @syscap SystemCapability.Security.CryptoFramework 4073 * @since 9 4074 */ 4075 /** 4076 * Used to append the message need to be signed. 4077 * 4078 * @param { DataBlob } data - the data need to be signed. 4079 * @param { AsyncCallback<void> } callback - the call back function return nothing. 4080 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4081 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4082 * @throws { BusinessError } 17620001 - memory operation failed. 4083 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4084 * @throws { BusinessError } 17630001 - crypto operation error. 4085 * @syscap SystemCapability.Security.CryptoFramework 4086 * @crossplatform 4087 * @since 11 4088 */ 4089 /** 4090 * Used to append the message need to be signed. 4091 * This API can be called only after the Sign instance is initialized by using init. 4092 * 4093 * @param { DataBlob } data - the data need to be signed. 4094 * @param { AsyncCallback<void> } callback - the call back function return nothing. 4095 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4096 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4097 * @throws { BusinessError } 17620001 - memory operation failed. 4098 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4099 * @throws { BusinessError } 17630001 - crypto operation error. 4100 * @syscap SystemCapability.Security.CryptoFramework.Signature 4101 * @crossplatform 4102 * @atomicservice 4103 * @since 12 4104 */ 4105 update(data: DataBlob, callback: AsyncCallback<void>): void; 4106 4107 /** 4108 * Used to append the message need to be signed. 4109 * 4110 * @param { DataBlob } data - the data need to be signed. 4111 * @returns { Promise<void> } return nothing. 4112 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4113 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4114 * @throws { BusinessError } 17620001 - memory operation failed. 4115 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4116 * @throws { BusinessError } 17630001 - crypto operation error. 4117 * @syscap SystemCapability.Security.CryptoFramework 4118 * @since 9 4119 */ 4120 /** 4121 * Used to append the message need to be signed. 4122 * 4123 * @param { DataBlob } data - the data need to be signed. 4124 * @returns { Promise<void> } return nothing. 4125 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4126 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4127 * @throws { BusinessError } 17620001 - memory operation failed. 4128 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4129 * @throws { BusinessError } 17630001 - crypto operation error. 4130 * @syscap SystemCapability.Security.CryptoFramework 4131 * @crossplatform 4132 * @since 11 4133 */ 4134 /** 4135 * Used to append the message need to be signed. 4136 * This API can be called only after the Sign instance is initialized by using init. 4137 * 4138 * @param { DataBlob } data - the data need to be signed. 4139 * @returns { Promise<void> } return nothing. 4140 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4141 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4142 * @throws { BusinessError } 17620001 - memory operation failed. 4143 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4144 * @throws { BusinessError } 17630001 - crypto operation error. 4145 * @syscap SystemCapability.Security.CryptoFramework.Signature 4146 * @crossplatform 4147 * @atomicservice 4148 * @since 12 4149 */ 4150 update(data: DataBlob): Promise<void>; 4151 4152 /** 4153 * Used to append the message need to be signed. 4154 * This API can be called only after the Sign instance is initialized by using init. 4155 * 4156 * @param { DataBlob } data - the data need to be signed. 4157 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4158 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4159 * @throws { BusinessError } 17620001 - memory operation failed. 4160 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4161 * @throws { BusinessError } 17630001 - crypto operation error. 4162 * @syscap SystemCapability.Security.CryptoFramework.Signature 4163 * @crossplatform 4164 * @atomicservice 4165 * @since 12 4166 */ 4167 updateSync(data: DataBlob): void; 4168 4169 /** 4170 * Used to sign message, include the update data. 4171 * 4172 * @param { DataBlob } data - the data need to be signed. 4173 * @param { AsyncCallback<DataBlob> } callback - return the signed message. 4174 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4175 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4176 * @throws { BusinessError } 17620001 - memory operation failed. 4177 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4178 * @throws { BusinessError } 17630001 - crypto operation error. 4179 * @syscap SystemCapability.Security.CryptoFramework 4180 * @since 9 4181 */ 4182 /** 4183 * Used to sign message, include the update data. 4184 * 4185 * @param { DataBlob } data - the data need to be signed. 4186 * @param { AsyncCallback<DataBlob> } callback - return the signed message. 4187 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4188 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4189 * @throws { BusinessError } 17620001 - memory operation failed. 4190 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4191 * @throws { BusinessError } 17630001 - crypto operation error. 4192 * @syscap SystemCapability.Security.CryptoFramework 4193 * @crossplatform 4194 * @since 11 4195 */ 4196 /** 4197 * Used to sign message, include the update data. 4198 * 4199 * @param { DataBlob } data - the data need to be signed. 4200 * @param { AsyncCallback<DataBlob> } callback - return the signed message. 4201 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4202 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4203 * @throws { BusinessError } 17620001 - memory operation failed. 4204 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4205 * @throws { BusinessError } 17630001 - crypto operation error. 4206 * @syscap SystemCapability.Security.CryptoFramework.Signature 4207 * @crossplatform 4208 * @atomicservice 4209 * @since 12 4210 */ 4211 sign(data: DataBlob, callback: AsyncCallback<DataBlob>): void; 4212 4213 /** 4214 * Used to sign message, include the update data. 4215 * 4216 * @param { DataBlob | null } data - the data need to be signed. 4217 * @param { AsyncCallback<DataBlob> } callback - return the signed message. 4218 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4219 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4220 * @throws { BusinessError } 17620001 - memory operation failed. 4221 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4222 * @throws { BusinessError } 17630001 - crypto operation error. 4223 * @syscap SystemCapability.Security.CryptoFramework 4224 * @since 10 4225 */ 4226 /** 4227 * Used to sign message, include the update data. 4228 * 4229 * @param { DataBlob | null } data - the data need to be signed. 4230 * @param { AsyncCallback<DataBlob> } callback - return the signed message. 4231 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4232 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4233 * @throws { BusinessError } 17620001 - memory operation failed. 4234 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4235 * @throws { BusinessError } 17630001 - crypto operation error. 4236 * @syscap SystemCapability.Security.CryptoFramework 4237 * @crossplatform 4238 * @since 11 4239 */ 4240 /** 4241 * Used to sign message, include the update data. 4242 * 4243 * @param { DataBlob | null } data - the data need to be signed. 4244 * @param { AsyncCallback<DataBlob> } callback - return the signed message. 4245 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4246 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4247 * @throws { BusinessError } 17620001 - memory operation failed. 4248 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4249 * @throws { BusinessError } 17630001 - crypto operation error. 4250 * @syscap SystemCapability.Security.CryptoFramework.Signature 4251 * @crossplatform 4252 * @atomicservice 4253 * @since 12 4254 */ 4255 sign(data: DataBlob | null, callback: AsyncCallback<DataBlob>): void; 4256 4257 /** 4258 * Used to append the message need to be signed. 4259 * 4260 * @param { DataBlob } data - the private key. 4261 * @returns { Promise<DataBlob> } return the signed message. 4262 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4263 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4264 * @throws { BusinessError } 17620001 - memory operation failed. 4265 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4266 * @throws { BusinessError } 17630001 - crypto operation error. 4267 * @syscap SystemCapability.Security.CryptoFramework 4268 * @since 9 4269 */ 4270 /** 4271 * Used to append the message need to be signed. 4272 * 4273 * @param { DataBlob } data - the private key. 4274 * @returns { Promise<DataBlob> } return the signed message. 4275 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4276 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4277 * @throws { BusinessError } 17620001 - memory operation failed. 4278 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4279 * @throws { BusinessError } 17630001 - crypto operation error. 4280 * @syscap SystemCapability.Security.CryptoFramework 4281 * @crossplatform 4282 * @since 11 4283 */ 4284 /** 4285 * Used to append the message need to be signed. 4286 * 4287 * @param { DataBlob } data - the private key. 4288 * @returns { Promise<DataBlob> } return the signed message. 4289 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4290 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4291 * @throws { BusinessError } 17620001 - memory operation failed. 4292 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4293 * @throws { BusinessError } 17630001 - crypto operation error. 4294 * @syscap SystemCapability.Security.CryptoFramework.Signature 4295 * @crossplatform 4296 * @atomicservice 4297 * @since 12 4298 */ 4299 sign(data: DataBlob): Promise<DataBlob>; 4300 4301 /** 4302 * Used to append the message need to be signed. 4303 * 4304 * @param { DataBlob | null } data - the private key. 4305 * @returns { Promise<DataBlob> } return the signed message. 4306 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4307 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4308 * @throws { BusinessError } 17620001 - memory operation failed. 4309 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4310 * @throws { BusinessError } 17630001 - crypto operation error. 4311 * @syscap SystemCapability.Security.CryptoFramework 4312 * @since 10 4313 */ 4314 /** 4315 * Used to append the message need to be signed. 4316 * 4317 * @param { DataBlob | null } data - the private key. 4318 * @returns { Promise<DataBlob> } return the signed message. 4319 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4320 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4321 * @throws { BusinessError } 17620001 - memory operation failed. 4322 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4323 * @throws { BusinessError } 17630001 - crypto operation error. 4324 * @syscap SystemCapability.Security.CryptoFramework 4325 * @crossplatform 4326 * @since 11 4327 */ 4328 /** 4329 * Used to append the message need to be signed. 4330 * 4331 * @param { DataBlob | null } data - the private key. 4332 * @returns { Promise<DataBlob> } return the signed message. 4333 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4334 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4335 * @throws { BusinessError } 17620001 - memory operation failed. 4336 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4337 * @throws { BusinessError } 17630001 - crypto operation error. 4338 * @syscap SystemCapability.Security.CryptoFramework.Signature 4339 * @crossplatform 4340 * @atomicservice 4341 * @since 12 4342 */ 4343 sign(data: DataBlob | null): Promise<DataBlob>; 4344 4345 /** 4346 * Used to append the message need to be signed. 4347 * 4348 * @param { DataBlob | null } data - the private key. 4349 * @returns { DataBlob } return the signed message. 4350 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4351 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4352 * @throws { BusinessError } 17620001 - memory operation failed. 4353 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4354 * @throws { BusinessError } 17630001 - crypto operation error. 4355 * @syscap SystemCapability.Security.CryptoFramework.Signature 4356 * @crossplatform 4357 * @atomicservice 4358 * @since 12 4359 */ 4360 signSync(data: DataBlob | null): DataBlob; 4361 4362 /** 4363 * Set the specified parameter to the sign object. 4364 * Currently, only the PSS_SALT_LEN parameter in RSA is supported. 4365 * 4366 * @param { SignSpecItem } itemType - indicates the specified parameter type. 4367 * @param { number } itemValue - the value of the specified parameter. 4368 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4369 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4370 * @throws { BusinessError } 801 - this operation is not supported. 4371 * @throws { BusinessError } 17620001 - memory operation failed. 4372 * @throws { BusinessError } 17630001 - crypto operation error. 4373 * @syscap SystemCapability.Security.CryptoFramework 4374 * @since 10 4375 */ 4376 /** 4377 * Set the specified parameter to the sign object. 4378 * Currently, only the PSS_SALT_LEN parameter in RSA is supported. 4379 * 4380 * @param { SignSpecItem } itemType - indicates the specified parameter type. 4381 * @param { number } itemValue - the value of the specified parameter. 4382 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4383 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4384 * @throws { BusinessError } 801 - this operation is not supported. 4385 * @throws { BusinessError } 17620001 - memory operation failed. 4386 * @throws { BusinessError } 17630001 - crypto operation error. 4387 * @syscap SystemCapability.Security.CryptoFramework 4388 * @crossplatform 4389 * @since 11 4390 */ 4391 /** 4392 * Set the specified parameter to the sign object. 4393 * Currently, only the PSS_SALT_LEN parameter in RSA is supported. 4394 * 4395 * @param { SignSpecItem } itemType - indicates the specified parameter type. 4396 * @param { number } itemValue - the value of the specified parameter. 4397 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4398 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4399 * @throws { BusinessError } 801 - this operation is not supported. 4400 * @throws { BusinessError } 17620001 - memory operation failed. 4401 * @throws { BusinessError } 17630001 - crypto operation error. 4402 * @syscap SystemCapability.Security.CryptoFramework.Signature 4403 * @crossplatform 4404 * @atomicservice 4405 * @since 12 4406 */ 4407 setSignSpec(itemType: SignSpecItem, itemValue: number): void; 4408 4409 /** 4410 * Set the specified parameter to the sign object. 4411 * Currently, only PSS_SALT_LEN in RSA and USER_ID in SM2 are supported. 4412 * 4413 * @param { SignSpecItem } itemType - indicates the specified parameter type. 4414 * @param { number | Uint8Array } itemValue - the value of the specified parameter. 4415 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4416 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4417 * @throws { BusinessError } 801 - this operation is not supported. 4418 * @throws { BusinessError } 17620001 - memory operation failed. 4419 * @throws { BusinessError } 17630001 - crypto operation error. 4420 * @syscap SystemCapability.Security.CryptoFramework 4421 * @crossplatform 4422 * @since 11 4423 */ 4424 /** 4425 * Set the specified parameter to the sign object. 4426 * Currently, only PSS_SALT_LEN in RSA and USER_ID in SM2 are supported. 4427 * 4428 * @param { SignSpecItem } itemType - indicates the specified parameter type. 4429 * @param { number | Uint8Array } itemValue - the value of the specified parameter. 4430 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4431 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4432 * @throws { BusinessError } 801 - this operation is not supported. 4433 * @throws { BusinessError } 17620001 - memory operation failed. 4434 * @throws { BusinessError } 17630001 - crypto operation error. 4435 * @syscap SystemCapability.Security.CryptoFramework.Signature 4436 * @crossplatform 4437 * @atomicservice 4438 * @since 12 4439 */ 4440 setSignSpec(itemType: SignSpecItem, itemValue: number | Uint8Array): void; 4441 4442 /** 4443 * Get the specified parameter from the sign object. 4444 * Currently, only PSS parameters in RSA is supported. 4445 * 4446 * @param { SignSpecItem } itemType - indicates the specified parameter type. 4447 * @returns { string | number } the value of the specified parameter. 4448 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4449 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4450 * @throws { BusinessError } 801 - this operation is not supported. 4451 * @throws { BusinessError } 17620001 - memory operation failed. 4452 * @throws { BusinessError } 17630001 - crypto operation error. 4453 * @syscap SystemCapability.Security.CryptoFramework 4454 * @since 10 4455 */ 4456 /** 4457 * Get the specified parameter from the sign object. 4458 * Currently, only PSS parameters in RSA is supported. 4459 * 4460 * @param { SignSpecItem } itemType - indicates the specified parameter type. 4461 * @returns { string | number } the value of the specified parameter. 4462 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4463 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4464 * @throws { BusinessError } 801 - this operation is not supported. 4465 * @throws { BusinessError } 17620001 - memory operation failed. 4466 * @throws { BusinessError } 17630001 - crypto operation error. 4467 * @syscap SystemCapability.Security.CryptoFramework 4468 * @crossplatform 4469 * @since 11 4470 */ 4471 /** 4472 * Get the specified parameter from the sign object. 4473 * Currently, only PSS parameters in RSA is supported. 4474 * 4475 * @param { SignSpecItem } itemType - indicates the specified parameter type. 4476 * @returns { string | number } the value of the specified parameter. 4477 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4478 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4479 * @throws { BusinessError } 801 - this operation is not supported. 4480 * @throws { BusinessError } 17620001 - memory operation failed. 4481 * @throws { BusinessError } 17630001 - crypto operation error. 4482 * @syscap SystemCapability.Security.CryptoFramework.Signature 4483 * @crossplatform 4484 * @atomicservice 4485 * @since 12 4486 */ 4487 getSignSpec(itemType: SignSpecItem): string | number; 4488 4489 /** 4490 * Indicates the algorithm name of the sign object. 4491 * 4492 * @type { string } 4493 * @readonly 4494 * @syscap SystemCapability.Security.CryptoFramework 4495 * @since 9 4496 */ 4497 /** 4498 * Indicates the algorithm name of the sign object. 4499 * 4500 * @type { string } 4501 * @readonly 4502 * @syscap SystemCapability.Security.CryptoFramework 4503 * @crossplatform 4504 * @since 11 4505 */ 4506 /** 4507 * Indicates the algorithm name of the sign object. 4508 * 4509 * @type { string } 4510 * @readonly 4511 * @syscap SystemCapability.Security.CryptoFramework.Signature 4512 * @crossplatform 4513 * @atomicservice 4514 * @since 12 4515 */ 4516 readonly algName: string; 4517 } 4518 4519 /** 4520 * Provides the Verify interface, which is used for verifying signatures. 4521 * 4522 * @typedef Verify 4523 * @syscap SystemCapability.Security.CryptoFramework 4524 * @since 9 4525 */ 4526 /** 4527 * Provides the Verify interface, which is used for verifying signatures. 4528 * 4529 * @typedef Verify 4530 * @syscap SystemCapability.Security.CryptoFramework 4531 * @crossplatform 4532 * @since 11 4533 */ 4534 /** 4535 * Provides the Verify interface, which is used for verifying signatures. 4536 * Before using any API of the Verify class, you must create a Verify instance by using createVerify. 4537 * Invoke init, update, and sign in this class in sequence to complete the signature verification. 4538 * 4539 * @typedef Verify 4540 * @syscap SystemCapability.Security.CryptoFramework.Signature 4541 * @crossplatform 4542 * @atomicservice 4543 * @since 12 4544 */ 4545 interface Verify { 4546 /** 4547 * Used to init environment. 4548 * 4549 * @param { PubKey } pubKey - the public key. 4550 * @param { AsyncCallback<void> } callback - return nothing. 4551 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4552 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4553 * @throws { BusinessError } 17620001 - memory operation failed. 4554 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4555 * @throws { BusinessError } 17630001 - crypto operation error. 4556 * @syscap SystemCapability.Security.CryptoFramework 4557 * @since 9 4558 */ 4559 /** 4560 * Used to init environment. 4561 * 4562 * @param { PubKey } pubKey - the public key. 4563 * @param { AsyncCallback<void> } callback - return nothing. 4564 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4565 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4566 * @throws { BusinessError } 17620001 - memory operation failed. 4567 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4568 * @throws { BusinessError } 17630001 - crypto operation error. 4569 * @syscap SystemCapability.Security.CryptoFramework 4570 * @crossplatform 4571 * @since 11 4572 */ 4573 /** 4574 * Initializes the Verify instance with a public key. 4575 * 4576 * @param { PubKey } pubKey - the public key. 4577 * @param { AsyncCallback<void> } callback - return nothing. 4578 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4579 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4580 * @throws { BusinessError } 17620001 - memory operation failed. 4581 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4582 * @throws { BusinessError } 17630001 - crypto operation error. 4583 * @syscap SystemCapability.Security.CryptoFramework.Signature 4584 * @crossplatform 4585 * @atomicservice 4586 * @since 12 4587 */ 4588 init(pubKey: PubKey, callback: AsyncCallback<void>): void; 4589 4590 /** 4591 * Used to init environment. 4592 * 4593 * @param { PubKey } pubKey - the public key. 4594 * @returns { Promise<void> } return nothing. 4595 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4596 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4597 * @throws { BusinessError } 17620001 - memory operation failed. 4598 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4599 * @throws { BusinessError } 17630001 - crypto operation error. 4600 * @syscap SystemCapability.Security.CryptoFramework 4601 * @since 9 4602 */ 4603 /** 4604 * Used to init environment. 4605 * 4606 * @param { PubKey } pubKey - the public key. 4607 * @returns { Promise<void> } return nothing. 4608 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4609 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4610 * @throws { BusinessError } 17620001 - memory operation failed. 4611 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4612 * @throws { BusinessError } 17630001 - crypto operation error. 4613 * @syscap SystemCapability.Security.CryptoFramework 4614 * @crossplatform 4615 * @since 11 4616 */ 4617 /** 4618 * Initializes the Verify instance with a public key. 4619 * 4620 * @param { PubKey } pubKey - the public key. 4621 * @returns { Promise<void> } return nothing. 4622 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4623 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4624 * @throws { BusinessError } 17620001 - memory operation failed. 4625 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4626 * @throws { BusinessError } 17630001 - crypto operation error. 4627 * @syscap SystemCapability.Security.CryptoFramework.Signature 4628 * @crossplatform 4629 * @atomicservice 4630 * @since 12 4631 */ 4632 init(pubKey: PubKey): Promise<void>; 4633 4634 /** 4635 * Initializes the Verify instance with a public key. 4636 * 4637 * @param { PubKey } pubKey - the public key. 4638 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4639 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4640 * @throws { BusinessError } 17620001 - memory operation failed. 4641 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4642 * @throws { BusinessError } 17630001 - crypto operation error. 4643 * @syscap SystemCapability.Security.CryptoFramework.Signature 4644 * @crossplatform 4645 * @atomicservice 4646 * @since 12 4647 */ 4648 initSync(pubKey: PubKey): void; 4649 4650 /** 4651 * Used to append the message need to be verified. 4652 * 4653 * @param { DataBlob } data - the data need to be verified. 4654 * @param { AsyncCallback<void> } callback - return nothing. 4655 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4656 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4657 * @throws { BusinessError } 17620001 - memory operation failed. 4658 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4659 * @throws { BusinessError } 17630001 - crypto operation error. 4660 * @syscap SystemCapability.Security.CryptoFramework 4661 * @since 9 4662 */ 4663 /** 4664 * Used to append the message need to be verified. 4665 * 4666 * @param { DataBlob } data - the data need to be verified. 4667 * @param { AsyncCallback<void> } callback - return nothing. 4668 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4669 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4670 * @throws { BusinessError } 17620001 - memory operation failed. 4671 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4672 * @throws { BusinessError } 17630001 - crypto operation error. 4673 * @syscap SystemCapability.Security.CryptoFramework 4674 * @crossplatform 4675 * @since 11 4676 */ 4677 /** 4678 * Used to append the message need to be verified. 4679 * 4680 * @param { DataBlob } data - the data need to be verified. 4681 * @param { AsyncCallback<void> } callback - return nothing. 4682 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4683 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4684 * @throws { BusinessError } 17620001 - memory operation failed. 4685 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4686 * @throws { BusinessError } 17630001 - crypto operation error. 4687 * @syscap SystemCapability.Security.CryptoFramework.Signature 4688 * @crossplatform 4689 * @atomicservice 4690 * @since 12 4691 */ 4692 update(data: DataBlob, callback: AsyncCallback<void>): void; 4693 4694 /** 4695 * Used to append the message need to be verified. 4696 * 4697 * @param { DataBlob } data - the data need to be verified. 4698 * @returns { Promise<void> } return nothing. 4699 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4700 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4701 * @throws { BusinessError } 17620001 - memory operation failed. 4702 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4703 * @throws { BusinessError } 17630001 - crypto operation error. 4704 * @syscap SystemCapability.Security.CryptoFramework 4705 * @since 9 4706 */ 4707 /** 4708 * Used to append the message need to be verified. 4709 * 4710 * @param { DataBlob } data - the data need to be verified. 4711 * @returns { Promise<void> } return nothing. 4712 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4713 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4714 * @throws { BusinessError } 17620001 - memory operation failed. 4715 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4716 * @throws { BusinessError } 17630001 - crypto operation error. 4717 * @syscap SystemCapability.Security.CryptoFramework 4718 * @crossplatform 4719 * @since 11 4720 */ 4721 /** 4722 * Used to append the message need to be verified. 4723 * 4724 * @param { DataBlob } data - the data need to be verified. 4725 * @returns { Promise<void> } return nothing. 4726 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4727 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4728 * @throws { BusinessError } 17620001 - memory operation failed. 4729 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4730 * @throws { BusinessError } 17630001 - crypto operation error. 4731 * @syscap SystemCapability.Security.CryptoFramework.Signature 4732 * @crossplatform 4733 * @atomicservice 4734 * @since 12 4735 */ 4736 update(data: DataBlob): Promise<void>; 4737 4738 /** 4739 * Used to append the message need to be verified. 4740 * 4741 * @param { DataBlob } data - the data need to be verified. 4742 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4743 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4744 * @throws { BusinessError } 17620001 - memory operation failed. 4745 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4746 * @throws { BusinessError } 17630001 - crypto operation error. 4747 * @syscap SystemCapability.Security.CryptoFramework.Signature 4748 * @crossplatform 4749 * @atomicservice 4750 * @since 12 4751 */ 4752 updateSync(data: DataBlob): void; 4753 4754 /** 4755 * Used to verify message, include the update data. 4756 * 4757 * @param { DataBlob } data - the data need to be verified. 4758 * @param { DataBlob } signatureData - the signature data. 4759 * @param { AsyncCallback<boolean> } callback - return the verify result. 4760 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4761 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4762 * @throws { BusinessError } 17620001 - memory operation failed. 4763 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4764 * @throws { BusinessError } 17630001 - crypto operation error. 4765 * @syscap SystemCapability.Security.CryptoFramework 4766 * @since 9 4767 */ 4768 /** 4769 * Used to verify message, include the update data. 4770 * 4771 * @param { DataBlob } data - the data need to be verified. 4772 * @param { DataBlob } signatureData - the signature data. 4773 * @param { AsyncCallback<boolean> } callback - return the verify result. 4774 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4775 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4776 * @throws { BusinessError } 17620001 - memory operation failed. 4777 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4778 * @throws { BusinessError } 17630001 - crypto operation error. 4779 * @syscap SystemCapability.Security.CryptoFramework 4780 * @crossplatform 4781 * @since 11 4782 */ 4783 /** 4784 * Used to verify message, include the update data. 4785 * 4786 * @param { DataBlob } data - the data need to be verified. 4787 * @param { DataBlob } signatureData - the signature data. 4788 * @param { AsyncCallback<boolean> } callback - return the verify result. 4789 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4790 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4791 * @throws { BusinessError } 17620001 - memory operation failed. 4792 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4793 * @throws { BusinessError } 17630001 - crypto operation error. 4794 * @syscap SystemCapability.Security.CryptoFramework.Signature 4795 * @crossplatform 4796 * @atomicservice 4797 * @since 12 4798 */ 4799 verify(data: DataBlob, signatureData: DataBlob, callback: AsyncCallback<boolean>): void; 4800 4801 /** 4802 * Used to verify message, include the update data. 4803 * 4804 * @param { DataBlob | null } data - the data need to be verified. 4805 * @param { DataBlob } signatureData - the signature data. 4806 * @param { AsyncCallback<boolean> } callback - return the verify result. 4807 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4808 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4809 * @throws { BusinessError } 17620001 - memory operation failed. 4810 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4811 * @throws { BusinessError } 17630001 - crypto operation error. 4812 * @syscap SystemCapability.Security.CryptoFramework 4813 * @since 10 4814 */ 4815 /** 4816 * Used to verify message, include the update data. 4817 * 4818 * @param { DataBlob | null } data - the data need to be verified. 4819 * @param { DataBlob } signatureData - the signature data. 4820 * @param { AsyncCallback<boolean> } callback - return the verify result. 4821 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4822 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4823 * @throws { BusinessError } 17620001 - memory operation failed. 4824 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4825 * @throws { BusinessError } 17630001 - crypto operation error. 4826 * @syscap SystemCapability.Security.CryptoFramework 4827 * @crossplatform 4828 * @since 11 4829 */ 4830 /** 4831 * Used to verify message, include the update data. 4832 * 4833 * @param { DataBlob | null } data - the data need to be verified. 4834 * @param { DataBlob } signatureData - the signature data. 4835 * @param { AsyncCallback<boolean> } callback - return the verify result. 4836 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4837 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4838 * @throws { BusinessError } 17620001 - memory operation failed. 4839 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4840 * @throws { BusinessError } 17630001 - crypto operation error. 4841 * @syscap SystemCapability.Security.CryptoFramework.Signature 4842 * @crossplatform 4843 * @atomicservice 4844 * @since 12 4845 */ 4846 verify(data: DataBlob | null, signatureData: DataBlob, callback: AsyncCallback<boolean>): void; 4847 4848 /** 4849 * Used to verify message, include the update data. 4850 * 4851 * @param { DataBlob } data - the data need to be verified. 4852 * @param { DataBlob } signatureData - the signature data. 4853 * @returns { Promise<boolean> } return the verify result. 4854 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4855 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4856 * @throws { BusinessError } 17620001 - memory operation failed. 4857 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4858 * @throws { BusinessError } 17630001 - crypto operation error. 4859 * @syscap SystemCapability.Security.CryptoFramework 4860 * @since 9 4861 */ 4862 /** 4863 * Used to verify message, include the update data. 4864 * 4865 * @param { DataBlob } data - the data need to be verified. 4866 * @param { DataBlob } signatureData - the signature data. 4867 * @returns { Promise<boolean> } return the verify result. 4868 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4869 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4870 * @throws { BusinessError } 17620001 - memory operation failed. 4871 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4872 * @throws { BusinessError } 17630001 - crypto operation error. 4873 * @syscap SystemCapability.Security.CryptoFramework 4874 * @crossplatform 4875 * @since 11 4876 */ 4877 /** 4878 * Used to verify message, include the update data. 4879 * 4880 * @param { DataBlob } data - the data need to be verified. 4881 * @param { DataBlob } signatureData - the signature data. 4882 * @returns { Promise<boolean> } return the verify result. 4883 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4884 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4885 * @throws { BusinessError } 17620001 - memory operation failed. 4886 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4887 * @throws { BusinessError } 17630001 - crypto operation error. 4888 * @syscap SystemCapability.Security.CryptoFramework.Signature 4889 * @crossplatform 4890 * @atomicservice 4891 * @since 12 4892 */ 4893 verify(data: DataBlob, signatureData: DataBlob): Promise<boolean>; 4894 4895 /** 4896 * Used to verify message, include the update data. 4897 * 4898 * @param { DataBlob | null } data - the data need to be verified. 4899 * @param { DataBlob } signatureData - the signature data. 4900 * @returns { Promise<boolean> } return the verify result. 4901 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4902 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4903 * @throws { BusinessError } 17620001 - memory operation failed. 4904 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4905 * @throws { BusinessError } 17630001 - crypto operation error. 4906 * @syscap SystemCapability.Security.CryptoFramework 4907 * @since 10 4908 */ 4909 /** 4910 * Used to verify message, include the update data. 4911 * 4912 * @param { DataBlob | null } data - the data need to be verified. 4913 * @param { DataBlob } signatureData - the signature data. 4914 * @returns { Promise<boolean> } return the verify result. 4915 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4916 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4917 * @throws { BusinessError } 17620001 - memory operation failed. 4918 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4919 * @throws { BusinessError } 17630001 - crypto operation error. 4920 * @syscap SystemCapability.Security.CryptoFramework 4921 * @crossplatform 4922 * @since 11 4923 */ 4924 /** 4925 * Used to verify message, include the update data. 4926 * 4927 * @param { DataBlob | null } data - the data need to be verified. 4928 * @param { DataBlob } signatureData - the signature data. 4929 * @returns { Promise<boolean> } return the verify result. 4930 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4931 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4932 * @throws { BusinessError } 17620001 - memory operation failed. 4933 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4934 * @throws { BusinessError } 17630001 - crypto operation error. 4935 * @syscap SystemCapability.Security.CryptoFramework.Signature 4936 * @crossplatform 4937 * @atomicservice 4938 * @since 12 4939 */ 4940 verify(data: DataBlob | null, signatureData: DataBlob): Promise<boolean>; 4941 4942 /** 4943 * Used to verify message, include the update data. 4944 * 4945 * @param { DataBlob | null } data - the data need to be verified. 4946 * @param { DataBlob } signatureData - the signature data. 4947 * @returns { boolean } return the verify result. 4948 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4949 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4950 * @throws { BusinessError } 17620001 - memory operation failed. 4951 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4952 * @throws { BusinessError } 17630001 - crypto operation error. 4953 * @syscap SystemCapability.Security.CryptoFramework.Signature 4954 * @crossplatform 4955 * @atomicservice 4956 * @since 12 4957 */ 4958 verifySync(data: DataBlob | null, signatureData: DataBlob): boolean; 4959 4960 /** 4961 * Used to recover signed data. 4962 * Currently, only RSA is supported. 4963 * 4964 * @param { DataBlob } signatureData - the signature data. 4965 * @returns { Promise<DataBlob | null> } the promise used to return the recovered data. 4966 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4967 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4968 * @throws { BusinessError } 17620001 - memory operation failed. 4969 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4970 * @throws { BusinessError } 17630001 - crypto operation error. 4971 * @syscap SystemCapability.Security.CryptoFramework.Signature 4972 * @crossplatform 4973 * @atomicservice 4974 * @since 12 4975 */ 4976 recover(signatureData: DataBlob): Promise<DataBlob | null>; 4977 4978 /** 4979 * Used to recover signed data. 4980 * Currently, only RSA is supported. 4981 * 4982 * @param { DataBlob } signatureData - the signature data. 4983 * @returns { DataBlob | null } return the recovered data. 4984 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 4985 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 4986 * @throws { BusinessError } 17620001 - memory operation failed. 4987 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 4988 * @throws { BusinessError } 17630001 - crypto operation error. 4989 * @syscap SystemCapability.Security.CryptoFramework.Signature 4990 * @crossplatform 4991 * @atomicservice 4992 * @since 12 4993 */ 4994 recoverSync(signatureData: DataBlob): DataBlob | null; 4995 4996 /** 4997 * Set the specified parameter to the verify object. 4998 * Currently, only the PSS_SALT_LEN parameter in RSA is supported. 4999 * 5000 * @param { SignSpecItem } itemType - indicates the specified parameter type. 5001 * @param { number } itemValue - the value of the specified parameter. 5002 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5003 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5004 * @throws { BusinessError } 801 - this operation is not supported. 5005 * @throws { BusinessError } 17620001 - memory operation failed. 5006 * @throws { BusinessError } 17630001 - crypto operation error. 5007 * @syscap SystemCapability.Security.CryptoFramework 5008 * @since 10 5009 */ 5010 /** 5011 * Set the specified parameter to the verify object. 5012 * Currently, only the PSS_SALT_LEN parameter in RSA is supported. 5013 * 5014 * @param { SignSpecItem } itemType - indicates the specified parameter type. 5015 * @param { number } itemValue - the value of the specified parameter. 5016 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5017 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5018 * @throws { BusinessError } 801 - this operation is not supported. 5019 * @throws { BusinessError } 17620001 - memory operation failed. 5020 * @throws { BusinessError } 17630001 - crypto operation error. 5021 * @syscap SystemCapability.Security.CryptoFramework 5022 * @crossplatform 5023 * @since 11 5024 */ 5025 /** 5026 * Set the specified parameter to the verify object. 5027 * Currently, only the PSS_SALT_LEN parameter in RSA is supported. 5028 * 5029 * @param { SignSpecItem } itemType - indicates the specified parameter type. 5030 * @param { number } itemValue - the value of the specified parameter. 5031 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5032 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5033 * @throws { BusinessError } 801 - this operation is not supported. 5034 * @throws { BusinessError } 17620001 - memory operation failed. 5035 * @throws { BusinessError } 17630001 - crypto operation error. 5036 * @syscap SystemCapability.Security.CryptoFramework.Signature 5037 * @crossplatform 5038 * @atomicservice 5039 * @since 12 5040 */ 5041 setVerifySpec(itemType: SignSpecItem, itemValue: number): void; 5042 5043 /** 5044 * Set the specified parameter to the verify object. 5045 * Currently, only PSS_SALT_LEN in RSA and USER_ID in SM2 are supported. 5046 * 5047 * @param { SignSpecItem } itemType - indicates the specified parameter type. 5048 * @param { number | Uint8Array } itemValue - the value of the specified parameter. 5049 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5050 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5051 * @throws { BusinessError } 801 - this operation is not supported. 5052 * @throws { BusinessError } 17620001 - memory operation failed. 5053 * @throws { BusinessError } 17630001 - crypto operation error. 5054 * @syscap SystemCapability.Security.CryptoFramework 5055 * @crossplatform 5056 * @since 11 5057 */ 5058 /** 5059 * Set the specified parameter to the verify object. 5060 * Currently, only PSS_SALT_LEN in RSA and USER_ID in SM2 are supported. 5061 * 5062 * @param { SignSpecItem } itemType - indicates the specified parameter type. 5063 * @param { number | Uint8Array } itemValue - the value of the specified parameter. 5064 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5065 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5066 * @throws { BusinessError } 801 - this operation is not supported. 5067 * @throws { BusinessError } 17620001 - memory operation failed. 5068 * @throws { BusinessError } 17630001 - crypto operation error. 5069 * @syscap SystemCapability.Security.CryptoFramework.Signature 5070 * @crossplatform 5071 * @atomicservice 5072 * @since 12 5073 */ 5074 setVerifySpec(itemType: SignSpecItem, itemValue: number | Uint8Array): void; 5075 5076 /** 5077 * Get the specified parameter from the verify object. 5078 * Currently, only PSS parameters in RSA is supported. 5079 * 5080 * @param { SignSpecItem } itemType - indicates the specified parameter type. 5081 * @returns { string | number } the value of the specified parameter. 5082 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5083 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5084 * @throws { BusinessError } 801 - this operation is not supported. 5085 * @throws { BusinessError } 17620001 - memory operation failed. 5086 * @throws { BusinessError } 17630001 - crypto operation error. 5087 * @syscap SystemCapability.Security.CryptoFramework 5088 * @since 10 5089 */ 5090 /** 5091 * Get the specified parameter from the verify object. 5092 * Currently, only PSS parameters in RSA is supported. 5093 * 5094 * @param { SignSpecItem } itemType - indicates the specified parameter type. 5095 * @returns { string | number } the value of the specified parameter. 5096 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5097 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5098 * @throws { BusinessError } 801 - this operation is not supported. 5099 * @throws { BusinessError } 17620001 - memory operation failed. 5100 * @throws { BusinessError } 17630001 - crypto operation error. 5101 * @syscap SystemCapability.Security.CryptoFramework 5102 * @crossplatform 5103 * @since 11 5104 */ 5105 /** 5106 * Get the specified parameter from the verify object. 5107 * Currently, only PSS parameters in RSA is supported. 5108 * 5109 * @param { SignSpecItem } itemType - indicates the specified parameter type. 5110 * @returns { string | number } the value of the specified parameter. 5111 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5112 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5113 * @throws { BusinessError } 801 - this operation is not supported. 5114 * @throws { BusinessError } 17620001 - memory operation failed. 5115 * @throws { BusinessError } 17630001 - crypto operation error. 5116 * @syscap SystemCapability.Security.CryptoFramework.Signature 5117 * @crossplatform 5118 * @atomicservice 5119 * @since 12 5120 */ 5121 getVerifySpec(itemType: SignSpecItem): string | number; 5122 5123 /** 5124 * Indicates the algorithm name of the verify object. 5125 * 5126 * @type { string } 5127 * @readonly 5128 * @syscap SystemCapability.Security.CryptoFramework 5129 * @since 9 5130 */ 5131 /** 5132 * Indicates the algorithm name of the verify object. 5133 * 5134 * @type { string } 5135 * @readonly 5136 * @syscap SystemCapability.Security.CryptoFramework 5137 * @crossplatform 5138 * @since 11 5139 */ 5140 /** 5141 * Indicates the algorithm name of the verify object. 5142 * 5143 * @type { string } 5144 * @readonly 5145 * @syscap SystemCapability.Security.CryptoFramework.Signature 5146 * @crossplatform 5147 * @atomicservice 5148 * @since 12 5149 */ 5150 readonly algName: string; 5151 } 5152 5153 /** 5154 * Create a sign object for generating signatures. 5155 * 5156 * @param { string } algName - indicates the algorithm name and params. 5157 * @returns { Sign } the sign class. 5158 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5159 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5160 * @throws { BusinessError } 801 - this operation is not supported. 5161 * @throws { BusinessError } 17620001 - memory operation failed. 5162 * @syscap SystemCapability.Security.CryptoFramework 5163 * @since 9 5164 */ 5165 /** 5166 * Create a sign object for generating signatures. 5167 * 5168 * @param { string } algName - indicates the algorithm name and params. 5169 * @returns { Sign } the sign class. 5170 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5171 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5172 * @throws { BusinessError } 801 - this operation is not supported. 5173 * @throws { BusinessError } 17620001 - memory operation failed. 5174 * @syscap SystemCapability.Security.CryptoFramework 5175 * @crossplatform 5176 * @since 11 5177 */ 5178 /** 5179 * Create a sign object for generating signatures. 5180 * 5181 * @param { string } algName - indicates the algorithm name and params. Multiple parameters need to be concatenated by "|". 5182 * @returns { Sign } the sign class. 5183 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5184 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5185 * @throws { BusinessError } 801 - this operation is not supported. 5186 * @throws { BusinessError } 17620001 - memory operation failed. 5187 * @syscap SystemCapability.Security.CryptoFramework.Signature 5188 * @crossplatform 5189 * @atomicservice 5190 * @since 12 5191 */ 5192 function createSign(algName: string): Sign; 5193 5194 /** 5195 * Create a verify object for verifying signatures. 5196 * 5197 * @param { string } algName - indicates the algorithm name and the parameters. 5198 * @returns { Verify } the verify class. 5199 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5200 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5201 * @throws { BusinessError } 801 - this operation is not supported. 5202 * @throws { BusinessError } 17620001 - memory operation failed. 5203 * @syscap SystemCapability.Security.CryptoFramework 5204 * @since 9 5205 */ 5206 /** 5207 * Create a verify object for verifying signatures. 5208 * 5209 * @param { string } algName - indicates the algorithm name and the parameters. 5210 * @returns { Verify } the verify class. 5211 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5212 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5213 * @throws { BusinessError } 801 - this operation is not supported. 5214 * @throws { BusinessError } 17620001 - memory operation failed. 5215 * @syscap SystemCapability.Security.CryptoFramework 5216 * @crossplatform 5217 * @since 11 5218 */ 5219 /** 5220 * Create a verify object for verifying signatures. 5221 * 5222 * @param { string } algName - indicates the algorithm name and the parameters. Multiple parameters need to be concatenated by "|". 5223 * @returns { Verify } the verify class. 5224 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5225 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5226 * @throws { BusinessError } 801 - this operation is not supported. 5227 * @throws { BusinessError } 17620001 - memory operation failed. 5228 * @syscap SystemCapability.Security.CryptoFramework.Signature 5229 * @crossplatform 5230 * @atomicservice 5231 * @since 12 5232 */ 5233 function createVerify(algName: string): Verify; 5234 5235 /** 5236 * Provides key agreement function. 5237 * 5238 * @typedef KeyAgreement 5239 * @syscap SystemCapability.Security.CryptoFramework 5240 * @since 9 5241 */ 5242 /** 5243 * Provides key agreement function. 5244 * 5245 * @typedef KeyAgreement 5246 * @syscap SystemCapability.Security.CryptoFramework 5247 * @crossplatform 5248 * @since 11 5249 */ 5250 /** 5251 * Provides key agreement function. 5252 * Before using any API of the KeyAgreement class, you must create a KeyAgreement instance by using createKeyAgreement. 5253 * 5254 * @typedef KeyAgreement 5255 * @syscap SystemCapability.Security.CryptoFramework.KeyAgreement 5256 * @crossplatform 5257 * @atomicservice 5258 * @since 12 5259 */ 5260 interface KeyAgreement { 5261 /** 5262 * Used to generate secret. 5263 * 5264 * @param { PriKey } priKey - the private key. 5265 * @param { PubKey } pubKey - the public key. 5266 * @param { AsyncCallback<DataBlob> } callback - return the secret. 5267 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5268 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5269 * @throws { BusinessError } 17620001 - memory operation failed. 5270 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 5271 * @throws { BusinessError } 17630001 - crypto operation error. 5272 * @syscap SystemCapability.Security.CryptoFramework 5273 * @since 9 5274 */ 5275 /** 5276 * Used to generate secret. 5277 * 5278 * @param { PriKey } priKey - the private key. 5279 * @param { PubKey } pubKey - the public key. 5280 * @param { AsyncCallback<DataBlob> } callback - return the secret. 5281 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5282 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5283 * @throws { BusinessError } 17620001 - memory operation failed. 5284 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 5285 * @throws { BusinessError } 17630001 - crypto operation error. 5286 * @syscap SystemCapability.Security.CryptoFramework 5287 * @crossplatform 5288 * @since 11 5289 */ 5290 /** 5291 * Generates a shared secret based on the given private key and public key. 5292 * 5293 * @param { PriKey } priKey - the private key. 5294 * @param { PubKey } pubKey - the public key. 5295 * @param { AsyncCallback<DataBlob> } callback - return the secret. 5296 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5297 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5298 * @throws { BusinessError } 17620001 - memory operation failed. 5299 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 5300 * @throws { BusinessError } 17630001 - crypto operation error. 5301 * @syscap SystemCapability.Security.CryptoFramework.KeyAgreement 5302 * @crossplatform 5303 * @atomicservice 5304 * @since 12 5305 */ 5306 generateSecret(priKey: PriKey, pubKey: PubKey, callback: AsyncCallback<DataBlob>): void; 5307 5308 /** 5309 * Used to generate secret. 5310 * 5311 * @param { PriKey } priKey - the private key. 5312 * @param { PubKey } pubKey - the public key. 5313 * @returns { Promise<DataBlob> } the promise used to return secret. 5314 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5315 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5316 * @throws { BusinessError } 17620001 - memory operation failed. 5317 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 5318 * @throws { BusinessError } 17630001 - crypto operation error. 5319 * @syscap SystemCapability.Security.CryptoFramework 5320 * @since 9 5321 */ 5322 /** 5323 * Used to generate secret. 5324 * 5325 * @param { PriKey } priKey - the private key. 5326 * @param { PubKey } pubKey - the public key. 5327 * @returns { Promise<DataBlob> } the promise used to return secret. 5328 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5329 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5330 * @throws { BusinessError } 17620001 - memory operation failed. 5331 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 5332 * @throws { BusinessError } 17630001 - crypto operation error. 5333 * @syscap SystemCapability.Security.CryptoFramework 5334 * @crossplatform 5335 * @since 11 5336 */ 5337 /** 5338 * Generates a shared secret based on the given private key and public key. 5339 * 5340 * @param { PriKey } priKey - the private key. 5341 * @param { PubKey } pubKey - the public key. 5342 * @returns { Promise<DataBlob> } the promise used to return secret. 5343 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5344 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5345 * @throws { BusinessError } 17620001 - memory operation failed. 5346 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 5347 * @throws { BusinessError } 17630001 - crypto operation error. 5348 * @syscap SystemCapability.Security.CryptoFramework.KeyAgreement 5349 * @crossplatform 5350 * @atomicservice 5351 * @since 12 5352 */ 5353 generateSecret(priKey: PriKey, pubKey: PubKey): Promise<DataBlob>; 5354 5355 /** 5356 * Generates a shared secret based on the given private key and public key. 5357 * 5358 * @param { PriKey } priKey - the private key. 5359 * @param { PubKey } pubKey - the public key. 5360 * @returns { DataBlob } the promise used to return secret. 5361 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5362 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5363 * @throws { BusinessError } 17620001 - memory operation failed. 5364 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 5365 * @throws { BusinessError } 17630001 - crypto operation error. 5366 * @syscap SystemCapability.Security.CryptoFramework.KeyAgreement 5367 * @crossplatform 5368 * @atomicservice 5369 * @since 12 5370 */ 5371 generateSecretSync(priKey: PriKey, pubKey: PubKey): DataBlob; 5372 5373 /** 5374 * Indicates the algorithm name. 5375 * 5376 * @type { string } 5377 * @readonly 5378 * @syscap SystemCapability.Security.CryptoFramework 5379 * @since 9 5380 */ 5381 /** 5382 * Indicates the algorithm name. 5383 * 5384 * @type { string } 5385 * @readonly 5386 * @syscap SystemCapability.Security.CryptoFramework 5387 * @crossplatform 5388 * @since 11 5389 */ 5390 /** 5391 * Indicates the algorithm name. 5392 * 5393 * @type { string } 5394 * @readonly 5395 * @syscap SystemCapability.Security.CryptoFramework.KeyAgreement 5396 * @crossplatform 5397 * @atomicservice 5398 * @since 12 5399 */ 5400 readonly algName: string; 5401 } 5402 5403 /** 5404 * Create a key agreement object. 5405 * 5406 * @param { string } algName - indicates the algorithm name and params. 5407 * @returns { KeyAgreement } the key agreement object. 5408 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5409 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5410 * @throws { BusinessError } 801 - this operation is not supported. 5411 * @throws { BusinessError } 17620001 - memory operation failed. 5412 * @syscap SystemCapability.Security.CryptoFramework 5413 * @since 9 5414 */ 5415 /** 5416 * Create a key agreement object. 5417 * 5418 * @param { string } algName - indicates the algorithm name and params. 5419 * @returns { KeyAgreement } the key agreement object. 5420 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5421 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5422 * @throws { BusinessError } 801 - this operation is not supported. 5423 * @throws { BusinessError } 17620001 - memory operation failed. 5424 * @syscap SystemCapability.Security.CryptoFramework 5425 * @crossplatform 5426 * @since 11 5427 */ 5428 /** 5429 * Create a key agreement object. 5430 * 5431 * @param { string } algName - indicates the algorithm name and params. Multiple parameters need to be concatenated by "|". 5432 * @returns { KeyAgreement } the key agreement object. 5433 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 5434 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 5435 * @throws { BusinessError } 801 - this operation is not supported. 5436 * @throws { BusinessError } 17620001 - memory operation failed. 5437 * @syscap SystemCapability.Security.CryptoFramework.KeyAgreement 5438 * @crossplatform 5439 * @atomicservice 5440 * @since 12 5441 */ 5442 function createKeyAgreement(algName: string): KeyAgreement; 5443 5444 /** 5445 * Enum for algorithm specified parameters. 5446 * 5447 * @enum { number } 5448 * @syscap SystemCapability.Security.CryptoFramework 5449 * @since 10 5450 */ 5451 /** 5452 * Enum for algorithm specified parameters. 5453 * 5454 * @enum { number } 5455 * @syscap SystemCapability.Security.CryptoFramework 5456 * @crossplatform 5457 * @since 11 5458 */ 5459 /** 5460 * Enum for algorithm specified parameters. 5461 * 5462 * @enum { number } 5463 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5464 * @crossplatform 5465 * @atomicservice 5466 * @since 12 5467 */ 5468 enum AsyKeySpecItem { 5469 /** 5470 * Indicates the DSA prime p. 5471 * 5472 * @syscap SystemCapability.Security.CryptoFramework 5473 * @since 10 5474 */ 5475 /** 5476 * Indicates the DSA prime p. 5477 * 5478 * @syscap SystemCapability.Security.CryptoFramework 5479 * @crossplatform 5480 * @since 11 5481 */ 5482 /** 5483 * Indicates the DSA prime p. 5484 * 5485 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5486 * @crossplatform 5487 * @atomicservice 5488 * @since 12 5489 */ 5490 DSA_P_BN = 101, 5491 5492 /** 5493 * Indicates the DSA sub-prime q. 5494 * 5495 * @syscap SystemCapability.Security.CryptoFramework 5496 * @since 10 5497 */ 5498 /** 5499 * Indicates the DSA sub-prime q. 5500 * 5501 * @syscap SystemCapability.Security.CryptoFramework 5502 * @crossplatform 5503 * @since 11 5504 */ 5505 /** 5506 * Indicates the DSA sub-prime q. 5507 * 5508 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5509 * @crossplatform 5510 * @atomicservice 5511 * @since 12 5512 */ 5513 DSA_Q_BN = 102, 5514 5515 /** 5516 * Indicates the DSA base g. 5517 * 5518 * @syscap SystemCapability.Security.CryptoFramework 5519 * @since 10 5520 */ 5521 /** 5522 * Indicates the DSA base g. 5523 * 5524 * @syscap SystemCapability.Security.CryptoFramework 5525 * @crossplatform 5526 * @since 11 5527 */ 5528 /** 5529 * Indicates the DSA base g. 5530 * 5531 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5532 * @crossplatform 5533 * @atomicservice 5534 * @since 12 5535 */ 5536 DSA_G_BN = 103, 5537 5538 /** 5539 * Indicates the DSA private key. 5540 * 5541 * @syscap SystemCapability.Security.CryptoFramework 5542 * @since 10 5543 */ 5544 /** 5545 * Indicates the DSA private key. 5546 * 5547 * @syscap SystemCapability.Security.CryptoFramework 5548 * @crossplatform 5549 * @since 11 5550 */ 5551 /** 5552 * Indicates the DSA private key. 5553 * 5554 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5555 * @crossplatform 5556 * @atomicservice 5557 * @since 12 5558 */ 5559 DSA_SK_BN = 104, 5560 5561 /** 5562 * Indicates the DSA public key. 5563 * 5564 * @syscap SystemCapability.Security.CryptoFramework 5565 * @since 10 5566 */ 5567 /** 5568 * Indicates the DSA public key. 5569 * 5570 * @syscap SystemCapability.Security.CryptoFramework 5571 * @crossplatform 5572 * @since 11 5573 */ 5574 /** 5575 * Indicates the DSA public key. 5576 * 5577 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5578 * @crossplatform 5579 * @atomicservice 5580 * @since 12 5581 */ 5582 DSA_PK_BN = 105, 5583 5584 /** 5585 * Indicates the prime p of an elliptic curve (EC) prime finite field. 5586 * 5587 * @syscap SystemCapability.Security.CryptoFramework 5588 * @since 10 5589 */ 5590 /** 5591 * Indicates the prime p of an elliptic curve (EC) prime finite field. 5592 * 5593 * @syscap SystemCapability.Security.CryptoFramework 5594 * @crossplatform 5595 * @since 11 5596 */ 5597 /** 5598 * Indicates the prime p of an elliptic curve (EC) prime finite field. 5599 * 5600 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5601 * @crossplatform 5602 * @atomicservice 5603 * @since 12 5604 */ 5605 ECC_FP_P_BN = 201, 5606 5607 /** 5608 * Indicates the first coefficient a of this elliptic curve. 5609 * 5610 * @syscap SystemCapability.Security.CryptoFramework 5611 * @since 10 5612 */ 5613 /** 5614 * Indicates the first coefficient a of this elliptic curve. 5615 * 5616 * @syscap SystemCapability.Security.CryptoFramework 5617 * @crossplatform 5618 * @since 11 5619 */ 5620 /** 5621 * Indicates the first coefficient a of this elliptic curve. 5622 * 5623 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5624 * @crossplatform 5625 * @atomicservice 5626 * @since 12 5627 */ 5628 ECC_A_BN = 202, 5629 5630 /** 5631 * Indicates the second coefficient b of this elliptic curve. 5632 * 5633 * @syscap SystemCapability.Security.CryptoFramework 5634 * @since 10 5635 */ 5636 /** 5637 * Indicates the second coefficient b of this elliptic curve. 5638 * 5639 * @syscap SystemCapability.Security.CryptoFramework 5640 * @crossplatform 5641 * @since 11 5642 */ 5643 /** 5644 * Indicates the second coefficient b of this elliptic curve. 5645 * 5646 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5647 * @crossplatform 5648 * @atomicservice 5649 * @since 12 5650 */ 5651 ECC_B_BN = 203, 5652 5653 /** 5654 * Indicates the affine x-coordinate of base point g. 5655 * 5656 * @syscap SystemCapability.Security.CryptoFramework 5657 * @since 10 5658 */ 5659 /** 5660 * Indicates the affine x-coordinate of base point g. 5661 * 5662 * @syscap SystemCapability.Security.CryptoFramework 5663 * @crossplatform 5664 * @since 11 5665 */ 5666 /** 5667 * Indicates the affine x-coordinate of base point g. 5668 * 5669 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5670 * @crossplatform 5671 * @atomicservice 5672 * @since 12 5673 */ 5674 ECC_G_X_BN = 204, 5675 5676 /** 5677 * Indicates the affine y-coordinate of base point g. 5678 * 5679 * @syscap SystemCapability.Security.CryptoFramework 5680 * @since 10 5681 */ 5682 /** 5683 * Indicates the affine y-coordinate of base point g. 5684 * 5685 * @syscap SystemCapability.Security.CryptoFramework 5686 * @crossplatform 5687 * @since 11 5688 */ 5689 /** 5690 * Indicates the affine y-coordinate of base point g. 5691 * 5692 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5693 * @crossplatform 5694 * @atomicservice 5695 * @since 12 5696 */ 5697 ECC_G_Y_BN = 205, 5698 5699 /** 5700 * Indicates the order of the base point g. 5701 * 5702 * @syscap SystemCapability.Security.CryptoFramework 5703 * @since 10 5704 */ 5705 /** 5706 * Indicates the order of the base point g. 5707 * 5708 * @syscap SystemCapability.Security.CryptoFramework 5709 * @crossplatform 5710 * @since 11 5711 */ 5712 /** 5713 * Indicates the order of the base point g. 5714 * 5715 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5716 * @crossplatform 5717 * @atomicservice 5718 * @since 12 5719 */ 5720 ECC_N_BN = 206, 5721 5722 /** 5723 * Indicates the cofactor of the elliptic curve. 5724 * 5725 * @syscap SystemCapability.Security.CryptoFramework 5726 * @since 10 5727 */ 5728 /** 5729 * Indicates the cofactor of the elliptic curve. 5730 * 5731 * @syscap SystemCapability.Security.CryptoFramework 5732 * @crossplatform 5733 * @since 11 5734 */ 5735 /** 5736 * Indicates the cofactor of the elliptic curve. 5737 * 5738 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5739 * @crossplatform 5740 * @atomicservice 5741 * @since 12 5742 */ 5743 ECC_H_NUM = 207, 5744 5745 /** 5746 * Indicates the private value of the ECC private key. 5747 * 5748 * @syscap SystemCapability.Security.CryptoFramework 5749 * @since 10 5750 */ 5751 /** 5752 * Indicates the private value of the ECC private key. 5753 * 5754 * @syscap SystemCapability.Security.CryptoFramework 5755 * @crossplatform 5756 * @since 11 5757 */ 5758 /** 5759 * Indicates the private value of the ECC private key. 5760 * 5761 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5762 * @crossplatform 5763 * @atomicservice 5764 * @since 12 5765 */ 5766 ECC_SK_BN = 208, 5767 5768 /** 5769 * Indicates the affine x-coordinate of a point, which is the public point of an ECC public key. 5770 * 5771 * @syscap SystemCapability.Security.CryptoFramework 5772 * @since 10 5773 */ 5774 /** 5775 * Indicates the affine x-coordinate of a point, which is the public point of an ECC public key. 5776 * 5777 * @syscap SystemCapability.Security.CryptoFramework 5778 * @crossplatform 5779 * @since 11 5780 */ 5781 /** 5782 * Indicates the affine x-coordinate of a point, which is the public point of an ECC public key. 5783 * 5784 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5785 * @crossplatform 5786 * @atomicservice 5787 * @since 12 5788 */ 5789 ECC_PK_X_BN = 209, 5790 5791 /** 5792 * Indicates the affine y-coordinate of a point, which is the public point of an ECC public key. 5793 * 5794 * @syscap SystemCapability.Security.CryptoFramework 5795 * @since 10 5796 */ 5797 /** 5798 * Indicates the affine y-coordinate of a point, which is the public point of an ECC public key. 5799 * 5800 * @syscap SystemCapability.Security.CryptoFramework 5801 * @crossplatform 5802 * @since 11 5803 */ 5804 /** 5805 * Indicates the affine y-coordinate of a point, which is the public point of an ECC public key. 5806 * 5807 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5808 * @crossplatform 5809 * @atomicservice 5810 * @since 12 5811 */ 5812 ECC_PK_Y_BN = 210, 5813 5814 /** 5815 * Indicates an elliptic curve finite field type. 5816 * 5817 * @syscap SystemCapability.Security.CryptoFramework 5818 * @since 10 5819 */ 5820 /** 5821 * Indicates an elliptic curve finite field type. 5822 * 5823 * @syscap SystemCapability.Security.CryptoFramework 5824 * @crossplatform 5825 * @since 11 5826 */ 5827 /** 5828 * Indicates an elliptic curve finite field type. 5829 * 5830 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5831 * @crossplatform 5832 * @atomicservice 5833 * @since 12 5834 */ 5835 ECC_FIELD_TYPE_STR = 211, 5836 5837 /** 5838 * Indicates the field size in bits. 5839 * For Fp field (an elliptic curve prime finite field with prime p), the field size is the size of prime p. 5840 * 5841 * @syscap SystemCapability.Security.CryptoFramework 5842 * @since 10 5843 */ 5844 /** 5845 * Indicates the field size in bits. 5846 * For Fp field (an elliptic curve prime finite field with prime p), the field size is the size of prime p. 5847 * 5848 * @syscap SystemCapability.Security.CryptoFramework 5849 * @crossplatform 5850 * @since 11 5851 */ 5852 /** 5853 * Indicates the field size in bits. 5854 * For Fp field (an elliptic curve prime finite field with prime p), the field size is the size of prime p. 5855 * 5856 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5857 * @crossplatform 5858 * @atomicservice 5859 * @since 12 5860 */ 5861 ECC_FIELD_SIZE_NUM = 212, 5862 5863 /** 5864 * Indicates the curve name according to SECG (Standards for Efficient Cryptography Group). 5865 * 5866 * @syscap SystemCapability.Security.CryptoFramework 5867 * @since 10 5868 */ 5869 /** 5870 * Indicates the curve name according to SECG (Standards for Efficient Cryptography Group). 5871 * 5872 * @syscap SystemCapability.Security.CryptoFramework 5873 * @crossplatform 5874 * @since 11 5875 */ 5876 /** 5877 * Indicates the curve name according to SECG (Standards for Efficient Cryptography Group). 5878 * 5879 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5880 * @crossplatform 5881 * @atomicservice 5882 * @since 12 5883 */ 5884 ECC_CURVE_NAME_STR = 213, 5885 5886 /** 5887 * Indicates the modulus n of RSA algorithm. 5888 * 5889 * @syscap SystemCapability.Security.CryptoFramework 5890 * @since 10 5891 */ 5892 /** 5893 * Indicates the modulus n of RSA algorithm. 5894 * 5895 * @syscap SystemCapability.Security.CryptoFramework 5896 * @crossplatform 5897 * @since 11 5898 */ 5899 /** 5900 * Indicates the modulus n of RSA algorithm. 5901 * 5902 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5903 * @crossplatform 5904 * @atomicservice 5905 * @since 12 5906 */ 5907 RSA_N_BN = 301, 5908 5909 /** 5910 * Indicates the private exponent d of RSA algorithm. 5911 * 5912 * @syscap SystemCapability.Security.CryptoFramework 5913 * @since 10 5914 */ 5915 /** 5916 * Indicates the private exponent d of RSA algorithm. 5917 * 5918 * @syscap SystemCapability.Security.CryptoFramework 5919 * @crossplatform 5920 * @since 11 5921 */ 5922 /** 5923 * Indicates the private exponent d of RSA algorithm. 5924 * 5925 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5926 * @crossplatform 5927 * @atomicservice 5928 * @since 12 5929 */ 5930 RSA_SK_BN = 302, 5931 5932 /** 5933 * Indicates the public exponent e of RSA algorithm. 5934 * 5935 * @syscap SystemCapability.Security.CryptoFramework 5936 * @since 10 5937 */ 5938 /** 5939 * Indicates the public exponent e of RSA algorithm. 5940 * 5941 * @syscap SystemCapability.Security.CryptoFramework 5942 * @crossplatform 5943 * @since 11 5944 */ 5945 /** 5946 * Indicates the public exponent e of RSA algorithm. 5947 * 5948 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5949 * @crossplatform 5950 * @atomicservice 5951 * @since 12 5952 */ 5953 RSA_PK_BN = 303, 5954 5955 /** 5956 * Indicates the prime p of DH algorithm. 5957 * 5958 * @syscap SystemCapability.Security.CryptoFramework 5959 * @crossplatform 5960 * @since 11 5961 */ 5962 /** 5963 * Indicates the prime p of DH algorithm. 5964 * 5965 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5966 * @crossplatform 5967 * @atomicservice 5968 * @since 12 5969 */ 5970 DH_P_BN = 401, 5971 5972 /** 5973 * Indicates the generator g of DH algorithm. 5974 * 5975 * @syscap SystemCapability.Security.CryptoFramework 5976 * @crossplatform 5977 * @since 11 5978 */ 5979 /** 5980 * Indicates the generator g of DH algorithm. 5981 * 5982 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 5983 * @crossplatform 5984 * @atomicservice 5985 * @since 12 5986 */ 5987 DH_G_BN = 402, 5988 5989 /** 5990 * Indicates the number of bits of the private key length used in the DH algorithm. 5991 * 5992 * @syscap SystemCapability.Security.CryptoFramework 5993 * @crossplatform 5994 * @since 11 5995 */ 5996 /** 5997 * Indicates the number of bits of the private key length used in the DH algorithm. 5998 * 5999 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6000 * @crossplatform 6001 * @atomicservice 6002 * @since 12 6003 */ 6004 DH_L_NUM = 403, 6005 6006 /** 6007 * Indicates the private value of the DH private key. 6008 * 6009 * @syscap SystemCapability.Security.CryptoFramework 6010 * @crossplatform 6011 * @since 11 6012 */ 6013 /** 6014 * Indicates the private value of the DH private key. 6015 * 6016 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6017 * @crossplatform 6018 * @atomicservice 6019 * @since 12 6020 */ 6021 DH_SK_BN = 404, 6022 6023 /** 6024 * Indicates the public value of the DH public key. 6025 * 6026 * @syscap SystemCapability.Security.CryptoFramework 6027 * @crossplatform 6028 * @since 11 6029 */ 6030 /** 6031 * Indicates the public value of the DH public key. 6032 * 6033 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6034 * @crossplatform 6035 * @atomicservice 6036 * @since 12 6037 */ 6038 DH_PK_BN = 405, 6039 6040 /** 6041 * Indicates the private value of the ED25519 private key. 6042 * 6043 * @syscap SystemCapability.Security.CryptoFramework 6044 * @crossplatform 6045 * @since 11 6046 */ 6047 /** 6048 * Indicates the private value of the ED25519 private key. 6049 * 6050 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6051 * @crossplatform 6052 * @atomicservice 6053 * @since 12 6054 */ 6055 ED25519_SK_BN = 501, 6056 6057 /** 6058 * Indicates the public value of the ED25519 public key. 6059 * 6060 * @syscap SystemCapability.Security.CryptoFramework 6061 * @crossplatform 6062 * @since 11 6063 */ 6064 /** 6065 * Indicates the public value of the ED25519 public key. 6066 * 6067 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6068 * @crossplatform 6069 * @atomicservice 6070 * @since 12 6071 */ 6072 ED25519_PK_BN = 502, 6073 6074 /** 6075 * Indicates the private value of the X25519 private key. 6076 * 6077 * @syscap SystemCapability.Security.CryptoFramework 6078 * @crossplatform 6079 * @since 11 6080 */ 6081 /** 6082 * Indicates the private value of the X25519 private key. 6083 * 6084 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6085 * @crossplatform 6086 * @atomicservice 6087 * @since 12 6088 */ 6089 X25519_SK_BN = 601, 6090 6091 /** 6092 * Indicates the public value of the X25519 public key. 6093 * 6094 * @syscap SystemCapability.Security.CryptoFramework 6095 * @crossplatform 6096 * @since 11 6097 */ 6098 /** 6099 * Indicates the public value of the X25519 public key. 6100 * 6101 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6102 * @crossplatform 6103 * @atomicservice 6104 * @since 12 6105 */ 6106 X25519_PK_BN = 602 6107 } 6108 6109 /** 6110 * Enum for algorithm specified parameters type. 6111 * 6112 * @enum { number } 6113 * @syscap SystemCapability.Security.CryptoFramework 6114 * @since 10 6115 */ 6116 /** 6117 * Enum for algorithm specified parameters type. 6118 * 6119 * @enum { number } 6120 * @syscap SystemCapability.Security.CryptoFramework 6121 * @crossplatform 6122 * @since 11 6123 */ 6124 /** 6125 * Enum for algorithm specified parameters type. 6126 * 6127 * @enum { number } 6128 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6129 * @crossplatform 6130 * @atomicservice 6131 * @since 12 6132 */ 6133 enum AsyKeySpecType { 6134 /** 6135 * Indicates the common specified parameters. 6136 * 6137 * @syscap SystemCapability.Security.CryptoFramework 6138 * @since 10 6139 */ 6140 /** 6141 * Indicates the common specified parameters. 6142 * 6143 * @syscap SystemCapability.Security.CryptoFramework 6144 * @crossplatform 6145 * @since 11 6146 */ 6147 /** 6148 * Indicates the common specified parameters. 6149 * 6150 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6151 * @crossplatform 6152 * @atomicservice 6153 * @since 12 6154 */ 6155 COMMON_PARAMS_SPEC = 0, 6156 6157 /** 6158 * Indicates the specified parameters of private key. 6159 * 6160 * @syscap SystemCapability.Security.CryptoFramework 6161 * @since 10 6162 */ 6163 /** 6164 * Indicates the specified parameters of private key. 6165 * 6166 * @syscap SystemCapability.Security.CryptoFramework 6167 * @crossplatform 6168 * @since 11 6169 */ 6170 /** 6171 * Indicates the specified parameters of private key. 6172 * 6173 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6174 * @crossplatform 6175 * @atomicservice 6176 * @since 12 6177 */ 6178 PRIVATE_KEY_SPEC = 1, 6179 6180 /** 6181 * Indicates the specified parameters of public key. 6182 * 6183 * @syscap SystemCapability.Security.CryptoFramework 6184 * @since 10 6185 */ 6186 /** 6187 * Indicates the specified parameters of public key. 6188 * 6189 * @syscap SystemCapability.Security.CryptoFramework 6190 * @crossplatform 6191 * @since 11 6192 */ 6193 /** 6194 * Indicates the specified parameters of public key. 6195 * 6196 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6197 * @crossplatform 6198 * @atomicservice 6199 * @since 12 6200 */ 6201 PUBLIC_KEY_SPEC = 2, 6202 6203 /** 6204 * Indicates the specified parameters of keypair. 6205 * 6206 * @syscap SystemCapability.Security.CryptoFramework 6207 * @since 10 6208 */ 6209 /** 6210 * Indicates the specified parameters of keypair. 6211 * 6212 * @syscap SystemCapability.Security.CryptoFramework 6213 * @crossplatform 6214 * @since 11 6215 */ 6216 /** 6217 * Indicates the specified parameters of keypair. 6218 * 6219 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6220 * @crossplatform 6221 * @atomicservice 6222 * @since 12 6223 */ 6224 KEY_PAIR_SPEC = 3 6225 } 6226 6227 /** 6228 * Provides a base interface for specifying asymmetric key parameters. 6229 * 6230 * @typedef AsyKeySpec 6231 * @syscap SystemCapability.Security.CryptoFramework 6232 * @since 10 6233 */ 6234 /** 6235 * Provides a base interface for specifying asymmetric key parameters. 6236 * 6237 * @typedef AsyKeySpec 6238 * @syscap SystemCapability.Security.CryptoFramework 6239 * @crossplatform 6240 * @since 11 6241 */ 6242 /** 6243 * Provides a base interface for specifying asymmetric key parameters. 6244 * 6245 * @typedef AsyKeySpec 6246 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6247 * @crossplatform 6248 * @atomicservice 6249 * @since 12 6250 */ 6251 interface AsyKeySpec { 6252 /** 6253 * Indicates the algorithm name of the asymmetric key object. 6254 * 6255 * @type { string } 6256 * @syscap SystemCapability.Security.CryptoFramework 6257 * @since 10 6258 */ 6259 /** 6260 * Indicates the algorithm name of the asymmetric key object. 6261 * 6262 * @type { string } 6263 * @syscap SystemCapability.Security.CryptoFramework 6264 * @crossplatform 6265 * @since 11 6266 */ 6267 /** 6268 * Indicates the algorithm name of the asymmetric key object. 6269 * 6270 * @type { string } 6271 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6272 * @crossplatform 6273 * @atomicservice 6274 * @since 12 6275 */ 6276 algName: string; 6277 6278 /** 6279 * Indicates the type of the specified parameters. 6280 * 6281 * @type { AsyKeySpecType } 6282 * @syscap SystemCapability.Security.CryptoFramework 6283 * @since 10 6284 */ 6285 /** 6286 * Indicates the type of the specified parameters. 6287 * 6288 * @type { AsyKeySpecType } 6289 * @syscap SystemCapability.Security.CryptoFramework 6290 * @crossplatform 6291 * @since 11 6292 */ 6293 /** 6294 * Indicates the type of the specified parameters. 6295 * 6296 * @type { AsyKeySpecType } 6297 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6298 * @crossplatform 6299 * @atomicservice 6300 * @since 12 6301 */ 6302 specType: AsyKeySpecType; 6303 } 6304 6305 /** 6306 * Specifies the set of parameters used in the DSA algorithm. 6307 * 6308 * @typedef DSACommonParamsSpec 6309 * @extends AsyKeySpec 6310 * @syscap SystemCapability.Security.CryptoFramework 6311 * @since 10 6312 */ 6313 /** 6314 * Specifies the set of parameters used in the DSA algorithm. 6315 * 6316 * @typedef DSACommonParamsSpec 6317 * @extends AsyKeySpec 6318 * @syscap SystemCapability.Security.CryptoFramework 6319 * @crossplatform 6320 * @since 11 6321 */ 6322 /** 6323 * Specifies the set of parameters used in the DSA algorithm. It can be used to randomly generate a public or private key. 6324 * To generate a key based on key parameters, pass it to createAsyKeyGeneratorBySpec to create a key generator. 6325 * 6326 * @typedef DSACommonParamsSpec 6327 * @extends AsyKeySpec 6328 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6329 * @crossplatform 6330 * @atomicservice 6331 * @since 12 6332 */ 6333 interface DSACommonParamsSpec extends AsyKeySpec { 6334 /** 6335 * Indicates the DSA prime p. 6336 * 6337 * @type { bigint } 6338 * @syscap SystemCapability.Security.CryptoFramework 6339 * @since 10 6340 */ 6341 /** 6342 * Indicates the DSA prime p. 6343 * 6344 * @type { bigint } 6345 * @syscap SystemCapability.Security.CryptoFramework 6346 * @crossplatform 6347 * @since 11 6348 */ 6349 /** 6350 * Indicates the DSA prime p. 6351 * 6352 * @type { bigint } 6353 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6354 * @crossplatform 6355 * @atomicservice 6356 * @since 12 6357 */ 6358 p: bigint; 6359 6360 /** 6361 * Indicates the DSA sub-prime q. 6362 * 6363 * @type { bigint } 6364 * @syscap SystemCapability.Security.CryptoFramework 6365 * @since 10 6366 */ 6367 /** 6368 * Indicates the DSA sub-prime q. 6369 * 6370 * @type { bigint } 6371 * @syscap SystemCapability.Security.CryptoFramework 6372 * @crossplatform 6373 * @since 11 6374 */ 6375 /** 6376 * Indicates the DSA sub-prime q. 6377 * 6378 * @type { bigint } 6379 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6380 * @crossplatform 6381 * @atomicservice 6382 * @since 12 6383 */ 6384 q: bigint; 6385 6386 /** 6387 * Indicates the DSA base g. 6388 * 6389 * @type { bigint } 6390 * @syscap SystemCapability.Security.CryptoFramework 6391 * @since 10 6392 */ 6393 /** 6394 * Indicates the DSA base g. 6395 * 6396 * @type { bigint } 6397 * @syscap SystemCapability.Security.CryptoFramework 6398 * @crossplatform 6399 * @since 11 6400 */ 6401 /** 6402 * Indicates the DSA base g. 6403 * 6404 * @type { bigint } 6405 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6406 * @crossplatform 6407 * @atomicservice 6408 * @since 12 6409 */ 6410 g: bigint; 6411 } 6412 6413 /** 6414 * Specifies the DSA public key with its associated parameters. 6415 * 6416 * @typedef DSAPubKeySpec 6417 * @extends AsyKeySpec 6418 * @syscap SystemCapability.Security.CryptoFramework 6419 * @since 10 6420 */ 6421 /** 6422 * Specifies the DSA public key with its associated parameters. 6423 * 6424 * @typedef DSAPubKeySpec 6425 * @extends AsyKeySpec 6426 * @syscap SystemCapability.Security.CryptoFramework 6427 * @crossplatform 6428 * @since 11 6429 */ 6430 /** 6431 * Specifies the DSA public key with its associated parameters. 6432 * To generate a key based on key parameters, pass it to createAsyKeyGeneratorBySpec to create a key generator. 6433 * 6434 * @typedef DSAPubKeySpec 6435 * @extends AsyKeySpec 6436 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6437 * @crossplatform 6438 * @atomicservice 6439 * @since 12 6440 */ 6441 interface DSAPubKeySpec extends AsyKeySpec { 6442 /** 6443 * Indicates the DSA common parameters. 6444 * 6445 * @type { DSACommonParamsSpec } 6446 * @syscap SystemCapability.Security.CryptoFramework 6447 * @since 10 6448 */ 6449 /** 6450 * Indicates the DSA common parameters. 6451 * 6452 * @type { DSACommonParamsSpec } 6453 * @syscap SystemCapability.Security.CryptoFramework 6454 * @crossplatform 6455 * @since 11 6456 */ 6457 /** 6458 * Indicates the DSA common parameters. 6459 * 6460 * @type { DSACommonParamsSpec } 6461 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6462 * @crossplatform 6463 * @atomicservice 6464 * @since 12 6465 */ 6466 params: DSACommonParamsSpec; 6467 6468 /** 6469 * Indicates the DSA public key. 6470 * 6471 * @type { bigint } 6472 * @syscap SystemCapability.Security.CryptoFramework 6473 * @since 10 6474 */ 6475 /** 6476 * Indicates the DSA public key. 6477 * 6478 * @type { bigint } 6479 * @syscap SystemCapability.Security.CryptoFramework 6480 * @crossplatform 6481 * @since 11 6482 */ 6483 /** 6484 * Indicates the DSA public key. 6485 * 6486 * @type { bigint } 6487 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6488 * @crossplatform 6489 * @atomicservice 6490 * @since 12 6491 */ 6492 pk: bigint; 6493 } 6494 6495 /** 6496 * Specifies the DSA keypair with its associated parameters. 6497 * 6498 * @typedef DSAKeyPairSpec 6499 * @extends AsyKeySpec 6500 * @syscap SystemCapability.Security.CryptoFramework 6501 * @since 10 6502 */ 6503 /** 6504 * Specifies the DSA keypair with its associated parameters. 6505 * 6506 * @typedef DSAKeyPairSpec 6507 * @extends AsyKeySpec 6508 * @syscap SystemCapability.Security.CryptoFramework 6509 * @crossplatform 6510 * @since 11 6511 */ 6512 /** 6513 * Specifies the DSA keypair with its associated parameters. 6514 * To generate a key based on key parameters, pass it to createAsyKeyGeneratorBySpec to create a key generator. 6515 * 6516 * @typedef DSAKeyPairSpec 6517 * @extends AsyKeySpec 6518 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6519 * @crossplatform 6520 * @atomicservice 6521 * @since 12 6522 */ 6523 interface DSAKeyPairSpec extends AsyKeySpec { 6524 /** 6525 * Indicates the DSA common parameters. 6526 * 6527 * @type { DSACommonParamsSpec } 6528 * @syscap SystemCapability.Security.CryptoFramework 6529 * @since 10 6530 */ 6531 /** 6532 * Indicates the DSA common parameters. 6533 * 6534 * @type { DSACommonParamsSpec } 6535 * @syscap SystemCapability.Security.CryptoFramework 6536 * @crossplatform 6537 * @since 11 6538 */ 6539 /** 6540 * Indicates the DSA common parameters. 6541 * 6542 * @type { DSACommonParamsSpec } 6543 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6544 * @crossplatform 6545 * @atomicservice 6546 * @since 12 6547 */ 6548 params: DSACommonParamsSpec; 6549 6550 /** 6551 * Indicates the DSA private key. 6552 * 6553 * @type { bigint } 6554 * @syscap SystemCapability.Security.CryptoFramework 6555 * @since 10 6556 */ 6557 /** 6558 * Indicates the DSA private key. 6559 * 6560 * @type { bigint } 6561 * @syscap SystemCapability.Security.CryptoFramework 6562 * @crossplatform 6563 * @since 11 6564 */ 6565 /** 6566 * Indicates the DSA private key. 6567 * 6568 * @type { bigint } 6569 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6570 * @crossplatform 6571 * @atomicservice 6572 * @since 12 6573 */ 6574 sk: bigint; 6575 6576 /** 6577 * Indicates the DSA public key. 6578 * 6579 * @type { bigint } 6580 * @syscap SystemCapability.Security.CryptoFramework 6581 * @since 10 6582 */ 6583 /** 6584 * Indicates the DSA public key. 6585 * 6586 * @type { bigint } 6587 * @syscap SystemCapability.Security.CryptoFramework 6588 * @crossplatform 6589 * @since 11 6590 */ 6591 /** 6592 * Indicates the DSA public key. 6593 * 6594 * @type { bigint } 6595 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6596 * @crossplatform 6597 * @atomicservice 6598 * @since 12 6599 */ 6600 pk: bigint; 6601 } 6602 6603 /** 6604 * Specifies an elliptic curve finite field. 6605 * 6606 * @typedef ECField 6607 * @syscap SystemCapability.Security.CryptoFramework 6608 * @since 10 6609 */ 6610 /** 6611 * Specifies an elliptic curve finite field. 6612 * 6613 * @typedef ECField 6614 * @syscap SystemCapability.Security.CryptoFramework 6615 * @crossplatform 6616 * @since 11 6617 */ 6618 /** 6619 * Specifies an elliptic curve finite field. Currently, only the Fp field is supported. 6620 * 6621 * @typedef ECField 6622 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6623 * @crossplatform 6624 * @atomicservice 6625 * @since 12 6626 */ 6627 interface ECField { 6628 /** 6629 * Indicates the type of an elliptic curve finite field. 6630 * Currently, only Fp (elliptic curve prime finite field) is supported. 6631 * 6632 * @type { string } 6633 * @syscap SystemCapability.Security.CryptoFramework 6634 * @since 10 6635 */ 6636 /** 6637 * Indicates the type of an elliptic curve finite field. 6638 * Currently, only Fp (elliptic curve prime finite field) is supported. 6639 * 6640 * @type { string } 6641 * @syscap SystemCapability.Security.CryptoFramework 6642 * @crossplatform 6643 * @since 11 6644 */ 6645 /** 6646 * Indicates the type of an elliptic curve finite field. 6647 * Currently, only Fp (elliptic curve prime finite field) is supported. 6648 * 6649 * @type { string } 6650 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6651 * @crossplatform 6652 * @atomicservice 6653 * @since 12 6654 */ 6655 fieldType: string; 6656 } 6657 6658 /** 6659 * Specifies an elliptic curve finite field with the prime p. 6660 * 6661 * @typedef ECFieldFp 6662 * @extends ECField 6663 * @syscap SystemCapability.Security.CryptoFramework 6664 * @since 10 6665 */ 6666 /** 6667 * Specifies an elliptic curve finite field with the prime p. 6668 * 6669 * @typedef ECFieldFp 6670 * @extends ECField 6671 * @syscap SystemCapability.Security.CryptoFramework 6672 * @crossplatform 6673 * @since 11 6674 */ 6675 /** 6676 * Specifies an elliptic curve finite field with the prime p. 6677 * 6678 * @typedef ECFieldFp 6679 * @extends ECField 6680 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6681 * @crossplatform 6682 * @atomicservice 6683 * @since 12 6684 */ 6685 interface ECFieldFp extends ECField { 6686 /** 6687 * Indicates the prime p. 6688 * 6689 * @type { bigint } 6690 * @syscap SystemCapability.Security.CryptoFramework 6691 * @since 10 6692 */ 6693 /** 6694 * Indicates the prime p. 6695 * 6696 * @type { bigint } 6697 * @syscap SystemCapability.Security.CryptoFramework 6698 * @crossplatform 6699 * @since 11 6700 */ 6701 /** 6702 * Indicates the prime p. 6703 * 6704 * @type { bigint } 6705 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6706 * @crossplatform 6707 * @atomicservice 6708 * @since 12 6709 */ 6710 p: bigint; 6711 } 6712 6713 /** 6714 * Represents a point on an elliptic curve in affine coordinates. 6715 * 6716 * @typedef Point 6717 * @syscap SystemCapability.Security.CryptoFramework 6718 * @since 10 6719 */ 6720 /** 6721 * Represents a point on an elliptic curve in affine coordinates. 6722 * 6723 * @typedef Point 6724 * @syscap SystemCapability.Security.CryptoFramework 6725 * @crossplatform 6726 * @since 11 6727 */ 6728 /** 6729 * Represents a point on an elliptic curve in affine coordinates. 6730 * 6731 * @typedef Point 6732 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6733 * @crossplatform 6734 * @atomicservice 6735 * @since 12 6736 */ 6737 interface Point { 6738 /** 6739 * Indicates the affine x-coordinate. 6740 * 6741 * @type { bigint } 6742 * @syscap SystemCapability.Security.CryptoFramework 6743 * @since 10 6744 */ 6745 /** 6746 * Indicates the affine x-coordinate. 6747 * 6748 * @type { bigint } 6749 * @syscap SystemCapability.Security.CryptoFramework 6750 * @crossplatform 6751 * @since 11 6752 */ 6753 /** 6754 * Indicates the affine x-coordinate. 6755 * 6756 * @type { bigint } 6757 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6758 * @crossplatform 6759 * @atomicservice 6760 * @since 12 6761 */ 6762 x: bigint; 6763 6764 /** 6765 * Indicates the affine y-coordinate. 6766 * 6767 * @type { bigint } 6768 * @syscap SystemCapability.Security.CryptoFramework 6769 * @since 10 6770 */ 6771 /** 6772 * Indicates the affine y-coordinate. 6773 * 6774 * @type { bigint } 6775 * @syscap SystemCapability.Security.CryptoFramework 6776 * @crossplatform 6777 * @since 11 6778 */ 6779 /** 6780 * Indicates the affine y-coordinate. 6781 * 6782 * @type { bigint } 6783 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6784 * @crossplatform 6785 * @atomicservice 6786 * @since 12 6787 */ 6788 y: bigint; 6789 } 6790 6791 /** 6792 * Specifies the set of common parameters used in the ECC algorithm. 6793 * 6794 * @typedef ECCCommonParamsSpec 6795 * @extends AsyKeySpec 6796 * @syscap SystemCapability.Security.CryptoFramework 6797 * @since 10 6798 */ 6799 /** 6800 * Specifies the set of common parameters used in the ECC algorithm. 6801 * 6802 * @typedef ECCCommonParamsSpec 6803 * @extends AsyKeySpec 6804 * @syscap SystemCapability.Security.CryptoFramework 6805 * @crossplatform 6806 * @since 11 6807 */ 6808 /** 6809 * Specifies the set of common parameters used in the ECC algorithm. It can be used to randomly generate a public or private key. 6810 * 6811 * @typedef ECCCommonParamsSpec 6812 * @extends AsyKeySpec 6813 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6814 * @crossplatform 6815 * @atomicservice 6816 * @since 12 6817 */ 6818 interface ECCCommonParamsSpec extends AsyKeySpec { 6819 /** 6820 * Indicates an elliptic curve finite field. 6821 * 6822 * @type { ECField } 6823 * @syscap SystemCapability.Security.CryptoFramework 6824 * @since 10 6825 */ 6826 /** 6827 * Indicates an elliptic curve finite field. 6828 * 6829 * @type { ECField } 6830 * @syscap SystemCapability.Security.CryptoFramework 6831 * @crossplatform 6832 * @since 11 6833 */ 6834 /** 6835 * Indicates an elliptic curve finite field. 6836 * 6837 * @type { ECField } 6838 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6839 * @crossplatform 6840 * @atomicservice 6841 * @since 12 6842 */ 6843 field: ECField; 6844 6845 /** 6846 * Indicates the first coefficient a of the elliptic curve. 6847 * 6848 * @type { bigint } 6849 * @syscap SystemCapability.Security.CryptoFramework 6850 * @since 10 6851 */ 6852 /** 6853 * Indicates the first coefficient a of the elliptic curve. 6854 * 6855 * @type { bigint } 6856 * @syscap SystemCapability.Security.CryptoFramework 6857 * @crossplatform 6858 * @since 11 6859 */ 6860 /** 6861 * Indicates the first coefficient a of the elliptic curve. 6862 * 6863 * @type { bigint } 6864 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6865 * @crossplatform 6866 * @atomicservice 6867 * @since 12 6868 */ 6869 a: bigint; 6870 6871 /** 6872 * Indicates the second coefficient b of the elliptic curve. 6873 * 6874 * @type { bigint } 6875 * @syscap SystemCapability.Security.CryptoFramework 6876 * @since 10 6877 */ 6878 /** 6879 * Indicates the second coefficient b of the elliptic curve. 6880 * 6881 * @type { bigint } 6882 * @syscap SystemCapability.Security.CryptoFramework 6883 * @crossplatform 6884 * @since 11 6885 */ 6886 /** 6887 * Indicates the second coefficient b of the elliptic curve. 6888 * 6889 * @type { bigint } 6890 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6891 * @crossplatform 6892 * @atomicservice 6893 * @since 12 6894 */ 6895 b: bigint; 6896 6897 /** 6898 * Indicates the base point g. 6899 * 6900 * @type { Point } 6901 * @syscap SystemCapability.Security.CryptoFramework 6902 * @since 10 6903 */ 6904 /** 6905 * Indicates the base point g. 6906 * 6907 * @type { Point } 6908 * @syscap SystemCapability.Security.CryptoFramework 6909 * @crossplatform 6910 * @since 11 6911 */ 6912 /** 6913 * Indicates the base point g. 6914 * 6915 * @type { Point } 6916 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6917 * @crossplatform 6918 * @atomicservice 6919 * @since 12 6920 */ 6921 g: Point; 6922 6923 /** 6924 * Indicates the order of the base point g. 6925 * 6926 * @type { bigint } 6927 * @syscap SystemCapability.Security.CryptoFramework 6928 * @since 10 6929 */ 6930 /** 6931 * Indicates the order of the base point g. 6932 * 6933 * @type { bigint } 6934 * @syscap SystemCapability.Security.CryptoFramework 6935 * @crossplatform 6936 * @since 11 6937 */ 6938 /** 6939 * Indicates the order of the base point g. 6940 * 6941 * @type { bigint } 6942 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6943 * @crossplatform 6944 * @atomicservice 6945 * @since 12 6946 */ 6947 n: bigint; 6948 6949 /** 6950 * Indicates the cofactor h. 6951 * 6952 * @type { number } 6953 * @syscap SystemCapability.Security.CryptoFramework 6954 * @since 10 6955 */ 6956 /** 6957 * Indicates the cofactor h. 6958 * 6959 * @type { number } 6960 * @syscap SystemCapability.Security.CryptoFramework 6961 * @crossplatform 6962 * @since 11 6963 */ 6964 /** 6965 * Indicates the cofactor h. 6966 * 6967 * @type { number } 6968 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 6969 * @crossplatform 6970 * @atomicservice 6971 * @since 12 6972 */ 6973 h: number; 6974 } 6975 6976 /** 6977 * Specifies the ECC private key with its associated parameters. 6978 * 6979 * @typedef ECCPriKeySpec 6980 * @extends AsyKeySpec 6981 * @syscap SystemCapability.Security.CryptoFramework 6982 * @since 10 6983 */ 6984 /** 6985 * Specifies the ECC private key with its associated parameters. 6986 * 6987 * @typedef ECCPriKeySpec 6988 * @extends AsyKeySpec 6989 * @syscap SystemCapability.Security.CryptoFramework 6990 * @crossplatform 6991 * @since 11 6992 */ 6993 /** 6994 * Specifies the ECC private key with its associated parameters. 6995 * To generate a key based on key parameters, pass it to createAsyKeyGeneratorBySpec to create a key generator. 6996 * 6997 * @typedef ECCPriKeySpec 6998 * @extends AsyKeySpec 6999 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7000 * @crossplatform 7001 * @atomicservice 7002 * @since 12 7003 */ 7004 interface ECCPriKeySpec extends AsyKeySpec { 7005 /** 7006 * Indicates the ECC common parameters. 7007 * 7008 * @type { ECCCommonParamsSpec } 7009 * @syscap SystemCapability.Security.CryptoFramework 7010 * @since 10 7011 */ 7012 /** 7013 * Indicates the ECC common parameters. 7014 * 7015 * @type { ECCCommonParamsSpec } 7016 * @syscap SystemCapability.Security.CryptoFramework 7017 * @crossplatform 7018 * @since 11 7019 */ 7020 /** 7021 * Indicates the ECC common parameters. 7022 * 7023 * @type { ECCCommonParamsSpec } 7024 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7025 * @crossplatform 7026 * @atomicservice 7027 * @since 12 7028 */ 7029 params: ECCCommonParamsSpec; 7030 7031 /** 7032 * Indicates the private value of the ECC private key. 7033 * 7034 * @type { bigint } 7035 * @syscap SystemCapability.Security.CryptoFramework 7036 * @since 10 7037 */ 7038 /** 7039 * Indicates the private value of the ECC private key. 7040 * 7041 * @type { bigint } 7042 * @syscap SystemCapability.Security.CryptoFramework 7043 * @crossplatform 7044 * @since 11 7045 */ 7046 /** 7047 * Indicates the private value of the ECC private key. 7048 * 7049 * @type { bigint } 7050 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7051 * @crossplatform 7052 * @atomicservice 7053 * @since 12 7054 */ 7055 sk: bigint; 7056 } 7057 7058 /** 7059 * Specifies the ECC public key with its associated parameters. 7060 * 7061 * @typedef ECCPubKeySpec 7062 * @extends AsyKeySpec 7063 * @syscap SystemCapability.Security.CryptoFramework 7064 * @since 10 7065 */ 7066 /** 7067 * Specifies the ECC public key with its associated parameters. 7068 * 7069 * @typedef ECCPubKeySpec 7070 * @extends AsyKeySpec 7071 * @syscap SystemCapability.Security.CryptoFramework 7072 * @crossplatform 7073 * @since 11 7074 */ 7075 /** 7076 * Specifies the ECC public key with its associated parameters. 7077 * To generate a key based on key parameters, pass it to createAsyKeyGeneratorBySpec to create a key generator. 7078 * 7079 * @typedef ECCPubKeySpec 7080 * @extends AsyKeySpec 7081 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7082 * @crossplatform 7083 * @atomicservice 7084 * @since 12 7085 */ 7086 interface ECCPubKeySpec extends AsyKeySpec { 7087 /** 7088 * Indicates the ECC common parameters. 7089 * 7090 * @type { ECCCommonParamsSpec } 7091 * @syscap SystemCapability.Security.CryptoFramework 7092 * @since 10 7093 */ 7094 /** 7095 * Indicates the ECC common parameters. 7096 * 7097 * @type { ECCCommonParamsSpec } 7098 * @syscap SystemCapability.Security.CryptoFramework 7099 * @crossplatform 7100 * @since 11 7101 */ 7102 /** 7103 * Indicates the ECC common parameters. 7104 * 7105 * @type { ECCCommonParamsSpec } 7106 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7107 * @crossplatform 7108 * @atomicservice 7109 * @since 12 7110 */ 7111 params: ECCCommonParamsSpec; 7112 7113 /** 7114 * Indicates the public point of the ECC public key. 7115 * 7116 * @type { Point } 7117 * @syscap SystemCapability.Security.CryptoFramework 7118 * @since 10 7119 */ 7120 /** 7121 * Indicates the public point of the ECC public key. 7122 * 7123 * @type { Point } 7124 * @syscap SystemCapability.Security.CryptoFramework 7125 * @crossplatform 7126 * @since 11 7127 */ 7128 /** 7129 * Indicates the public point of the ECC public key. 7130 * 7131 * @type { Point } 7132 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7133 * @crossplatform 7134 * @atomicservice 7135 * @since 12 7136 */ 7137 pk: Point; 7138 } 7139 7140 /** 7141 * Specifies the ECC keypair with its associated parameters. 7142 * 7143 * @typedef ECCKeyPairSpec 7144 * @extends AsyKeySpec 7145 * @syscap SystemCapability.Security.CryptoFramework 7146 * @since 10 7147 */ 7148 /** 7149 * Specifies the ECC keypair with its associated parameters. 7150 * 7151 * @typedef ECCKeyPairSpec 7152 * @extends AsyKeySpec 7153 * @syscap SystemCapability.Security.CryptoFramework 7154 * @crossplatform 7155 * @since 11 7156 */ 7157 /** 7158 * Specifies the ECC keypair with its associated parameters. 7159 * To generate a key based on key parameters, pass it to createAsyKeyGeneratorBySpec to create a key generator. 7160 * 7161 * @typedef ECCKeyPairSpec 7162 * @extends AsyKeySpec 7163 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7164 * @crossplatform 7165 * @atomicservice 7166 * @since 12 7167 */ 7168 interface ECCKeyPairSpec extends AsyKeySpec { 7169 /** 7170 * Indicates the ECC common parameters. 7171 * 7172 * @type { ECCCommonParamsSpec } 7173 * @syscap SystemCapability.Security.CryptoFramework 7174 * @since 10 7175 */ 7176 /** 7177 * Indicates the ECC common parameters. 7178 * 7179 * @type { ECCCommonParamsSpec } 7180 * @syscap SystemCapability.Security.CryptoFramework 7181 * @crossplatform 7182 * @since 11 7183 */ 7184 /** 7185 * Indicates the ECC common parameters. 7186 * 7187 * @type { ECCCommonParamsSpec } 7188 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7189 * @crossplatform 7190 * @atomicservice 7191 * @since 12 7192 */ 7193 params: ECCCommonParamsSpec; 7194 7195 /** 7196 * Indicates the private value of the ECC private key. 7197 * 7198 * @type { bigint } 7199 * @syscap SystemCapability.Security.CryptoFramework 7200 * @since 10 7201 */ 7202 /** 7203 * Indicates the private value of the ECC private key. 7204 * 7205 * @type { bigint } 7206 * @syscap SystemCapability.Security.CryptoFramework 7207 * @crossplatform 7208 * @since 11 7209 */ 7210 /** 7211 * Indicates the private value of the ECC private key. 7212 * 7213 * @type { bigint } 7214 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7215 * @crossplatform 7216 * @atomicservice 7217 * @since 12 7218 */ 7219 sk: bigint; 7220 7221 /** 7222 * Indicates the public point of the ECC public key. 7223 * 7224 * @type { Point } 7225 * @syscap SystemCapability.Security.CryptoFramework 7226 * @since 10 7227 */ 7228 /** 7229 * Indicates the public point of the ECC public key. 7230 * 7231 * @type { Point } 7232 * @syscap SystemCapability.Security.CryptoFramework 7233 * @crossplatform 7234 * @since 11 7235 */ 7236 /** 7237 * Indicates the public point of the ECC public key. 7238 * 7239 * @type { Point } 7240 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7241 * @crossplatform 7242 * @atomicservice 7243 * @since 12 7244 */ 7245 pk: Point; 7246 } 7247 7248 /** 7249 * Key utilities for ECC Algorithm. 7250 * 7251 * @syscap SystemCapability.Security.CryptoFramework 7252 * @crossplatform 7253 * @since 11 7254 */ 7255 /** 7256 * Provides APIs for generating common parameters for an asymmetric key pair based on the elliptic curve name. 7257 * 7258 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7259 * @crossplatform 7260 * @atomicservice 7261 * @since 12 7262 */ 7263 class ECCKeyUtil { 7264 /** 7265 * Create the common parameter set based on the curve name. 7266 * 7267 * @param { string } curveName - indicates curve name according to the ECC elliptic curve. 7268 * @returns { ECCCommonParamsSpec } the ECC common params spec obj. 7269 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 7270 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7271 * @throws { BusinessError } 801 - this operation is not supported. 7272 * @throws { BusinessError } 17620001 - memory operation failed. 7273 * @static 7274 * @syscap SystemCapability.Security.CryptoFramework 7275 * @crossplatform 7276 * @since 11 7277 */ 7278 /** 7279 * Generates common parameters for an asymmetric key pair based on the specified name identifier (NID) of an elliptic curve. 7280 * 7281 * @param { string } curveName - indicates curve name according to the ECC elliptic curve. 7282 * @returns { ECCCommonParamsSpec } the ECC common params spec obj. 7283 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 7284 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7285 * @throws { BusinessError } 801 - this operation is not supported. 7286 * @throws { BusinessError } 17620001 - memory operation failed. 7287 * @static 7288 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7289 * @crossplatform 7290 * @atomicservice 7291 * @since 12 7292 */ 7293 static genECCCommonParamsSpec(curveName: string): ECCCommonParamsSpec; 7294 7295 /** 7296 * Used to convert the encoded point data to a point object, according to the ECC curve name. 7297 * 7298 * @param { string } curveName - indicates curve name according to the ECC elliptic curve. 7299 * @param { Uint8Array } encodedPoint - the encoded ECC point data. 7300 * @returns { Point } the ECC point object. 7301 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 7302 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7303 * @throws { BusinessError } 17620001 - memory operation failed. 7304 * @throws { BusinessError } 17630001 - crypto operation error. 7305 * @static 7306 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7307 * @crossplatform 7308 * @atomicservice 7309 * @since 12 7310 */ 7311 static convertPoint(curveName: string, encodedPoint: Uint8Array): Point; 7312 7313 /** 7314 * Used to get the encoded point data from a point object, according to the ECC curve name. 7315 * 7316 * @param { string } curveName - indicates curve name according to the ECC elliptic curve. 7317 * @param { Point } point - the ECC point object. 7318 * @param { string } format - indicates the format of the encoded point data. 7319 * @returns { Uint8Array } the encoded point data. 7320 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 7321 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7322 * @throws { BusinessError } 17620001 - memory operation failed. 7323 * @throws { BusinessError } 17630001 - crypto operation error. 7324 * @static 7325 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7326 * @crossplatform 7327 * @atomicservice 7328 * @since 12 7329 */ 7330 static getEncodedPoint(curveName: string, point: Point, format: string): Uint8Array; 7331 } 7332 7333 /** 7334 * Specifies the set of common parameters used in the DH algorithm. 7335 * 7336 * @typedef DHCommonParamsSpec 7337 * @extends AsyKeySpec 7338 * @syscap SystemCapability.Security.CryptoFramework 7339 * @crossplatform 7340 * @since 11 7341 */ 7342 /** 7343 * Specifies the set of common parameters used in the DH algorithm. It can be used to randomly generate a public or private key. 7344 * To generate a key based on key parameters, pass it to createAsyKeyGeneratorBySpec to create a key generator. 7345 * 7346 * @typedef DHCommonParamsSpec 7347 * @extends AsyKeySpec 7348 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7349 * @crossplatform 7350 * @atomicservice 7351 * @since 12 7352 */ 7353 interface DHCommonParamsSpec extends AsyKeySpec { 7354 /** 7355 * Indicates the prime p. 7356 * 7357 * @type { bigint } 7358 * @syscap SystemCapability.Security.CryptoFramework 7359 * @crossplatform 7360 * @since 11 7361 */ 7362 /** 7363 * Indicates the prime p. 7364 * 7365 * @type { bigint } 7366 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7367 * @crossplatform 7368 * @atomicservice 7369 * @since 12 7370 */ 7371 p: bigint; 7372 7373 /** 7374 * Indicates the generator g. 7375 * 7376 * @type { bigint } 7377 * @syscap SystemCapability.Security.CryptoFramework 7378 * @crossplatform 7379 * @since 11 7380 */ 7381 /** 7382 * Indicates the generator g. 7383 * 7384 * @type { bigint } 7385 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7386 * @crossplatform 7387 * @atomicservice 7388 * @since 12 7389 */ 7390 g: bigint; 7391 7392 /** 7393 * Indicates the byte length of the private key. 7394 * 7395 * @type { number } 7396 * @syscap SystemCapability.Security.CryptoFramework 7397 * @crossplatform 7398 * @since 11 7399 */ 7400 /** 7401 * Indicates the byte length of the private key. 7402 * 7403 * @type { number } 7404 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7405 * @crossplatform 7406 * @atomicservice 7407 * @since 12 7408 */ 7409 l: number; 7410 } 7411 7412 /** 7413 * Specifies the DH private key with its associated parameters. 7414 * 7415 * @typedef DHPriKeySpec 7416 * @extends AsyKeySpec 7417 * @syscap SystemCapability.Security.CryptoFramework 7418 * @crossplatform 7419 * @since 11 7420 */ 7421 /** 7422 * Specifies the DH private key with its associated parameters. 7423 * To generate a key based on key parameters, pass it to createAsyKeyGeneratorBySpec to create a key generator. 7424 * 7425 * @typedef DHPriKeySpec 7426 * @extends AsyKeySpec 7427 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7428 * @crossplatform 7429 * @atomicservice 7430 * @since 12 7431 */ 7432 interface DHPriKeySpec extends AsyKeySpec { 7433 /** 7434 * Indicates the DH common parameters. 7435 * 7436 * @type { DHCommonParamsSpec } 7437 * @syscap SystemCapability.Security.CryptoFramework 7438 * @crossplatform 7439 * @since 11 7440 */ 7441 /** 7442 * Indicates the DH common parameters. 7443 * 7444 * @type { DHCommonParamsSpec } 7445 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7446 * @crossplatform 7447 * @atomicservice 7448 * @since 12 7449 */ 7450 params: DHCommonParamsSpec; 7451 7452 /** 7453 * Indicates the private value of the DH private key. 7454 * 7455 * @type { bigint } 7456 * @syscap SystemCapability.Security.CryptoFramework 7457 * @crossplatform 7458 * @since 11 7459 */ 7460 /** 7461 * Indicates the private value of the DH private key. 7462 * 7463 * @type { bigint } 7464 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7465 * @crossplatform 7466 * @atomicservice 7467 * @since 12 7468 */ 7469 sk: bigint; 7470 } 7471 7472 /** 7473 * Specifies the DH public key with its associated parameters. 7474 * 7475 * @typedef DHPubKeySpec 7476 * @extends AsyKeySpec 7477 * @syscap SystemCapability.Security.CryptoFramework 7478 * @crossplatform 7479 * @since 11 7480 */ 7481 /** 7482 * Specifies the DH public key with its associated parameters. 7483 * To generate a key based on key parameters, pass it to createAsyKeyGeneratorBySpec to create a key generator. 7484 * 7485 * @typedef DHPubKeySpec 7486 * @extends AsyKeySpec 7487 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7488 * @crossplatform 7489 * @atomicservice 7490 * @since 12 7491 */ 7492 interface DHPubKeySpec extends AsyKeySpec { 7493 /** 7494 * Indicates the DH common parameters. 7495 * 7496 * @type { DHCommonParamsSpec } 7497 * @syscap SystemCapability.Security.CryptoFramework 7498 * @crossplatform 7499 * @since 11 7500 */ 7501 /** 7502 * Indicates the DH common parameters. 7503 * 7504 * @type { DHCommonParamsSpec } 7505 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7506 * @crossplatform 7507 * @atomicservice 7508 * @since 12 7509 */ 7510 params: DHCommonParamsSpec; 7511 7512 /** 7513 * Indicates the public value of the DH public key. 7514 * 7515 * @type { bigint } 7516 * @syscap SystemCapability.Security.CryptoFramework 7517 * @crossplatform 7518 * @since 11 7519 */ 7520 /** 7521 * Indicates the public value of the DH public key. 7522 * 7523 * @type { bigint } 7524 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7525 * @crossplatform 7526 * @atomicservice 7527 * @since 12 7528 */ 7529 pk: bigint; 7530 } 7531 7532 /** 7533 * Specifies the DH keypair with its associated parameters. 7534 * 7535 * @typedef DHKeyPairSpec 7536 * @extends AsyKeySpec 7537 * @syscap SystemCapability.Security.CryptoFramework 7538 * @crossplatform 7539 * @since 11 7540 */ 7541 /** 7542 * Specifies the DH keypair with its associated parameters. 7543 * To generate a key based on key parameters, pass it to createAsyKeyGeneratorBySpec to create a key generator. 7544 * 7545 * @typedef DHKeyPairSpec 7546 * @extends AsyKeySpec 7547 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7548 * @crossplatform 7549 * @atomicservice 7550 * @since 12 7551 */ 7552 interface DHKeyPairSpec extends AsyKeySpec { 7553 /** 7554 * Indicates the DH common parameters. 7555 * 7556 * @type { DHCommonParamsSpec } 7557 * @syscap SystemCapability.Security.CryptoFramework 7558 * @crossplatform 7559 * @since 11 7560 */ 7561 /** 7562 * Indicates the DH common parameters. 7563 * 7564 * @type { DHCommonParamsSpec } 7565 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7566 * @crossplatform 7567 * @atomicservice 7568 * @since 12 7569 */ 7570 params: DHCommonParamsSpec; 7571 7572 /** 7573 * Indicates the private value of the DH private key. 7574 * 7575 * @type { bigint } 7576 * @syscap SystemCapability.Security.CryptoFramework 7577 * @crossplatform 7578 * @since 11 7579 */ 7580 /** 7581 * Indicates the private value of the DH private key. 7582 * 7583 * @type { bigint } 7584 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7585 * @crossplatform 7586 * @atomicservice 7587 * @since 12 7588 */ 7589 sk: bigint; 7590 7591 /** 7592 * Indicates the public value of the DH public key. 7593 * 7594 * @type { bigint } 7595 * @syscap SystemCapability.Security.CryptoFramework 7596 * @crossplatform 7597 * @since 11 7598 */ 7599 /** 7600 * Indicates the public value of the DH public key. 7601 * 7602 * @type { bigint } 7603 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7604 * @crossplatform 7605 * @atomicservice 7606 * @since 12 7607 */ 7608 pk: bigint; 7609 } 7610 7611 /** 7612 * Key utilities for DH Algorithm. 7613 * 7614 * @syscap SystemCapability.Security.CryptoFramework 7615 * @crossplatform 7616 * @since 11 7617 */ 7618 /** 7619 * Provides APIs for generating common parameters for a DH key based on the prime p length and the private key length. 7620 * 7621 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7622 * @crossplatform 7623 * @atomicservice 7624 * @since 12 7625 */ 7626 class DHKeyUtil { 7627 /** 7628 * Create the common parameter set. 7629 * 7630 * @param { number } pLen - indicates the byte length of the prime p. 7631 * @param { number } [skLen] - indicates the byte length of the private key. 7632 * @returns { DHCommonParamsSpec } the DH common params spec obj. 7633 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 7634 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7635 * @throws { BusinessError } 801 - this operation is not supported. 7636 * @throws { BusinessError } 17620001 - memory operation failed. 7637 * @throws { BusinessError } 17630001 - crypto operation error. 7638 * @static 7639 * @syscap SystemCapability.Security.CryptoFramework 7640 * @crossplatform 7641 * @since 11 7642 */ 7643 /** 7644 * Generates common parameters for a DH key based on the prime p length and the private key length. 7645 * 7646 * @param { number } pLen - indicates the byte length of the prime p. 7647 * @param { number } [skLen] - indicates the byte length of the private key. 7648 * @returns { DHCommonParamsSpec } the DH common params spec obj. 7649 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 7650 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 7651 * @throws { BusinessError } 801 - this operation is not supported. 7652 * @throws { BusinessError } 17620001 - memory operation failed. 7653 * @throws { BusinessError } 17630001 - crypto operation error. 7654 * @static 7655 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7656 * @crossplatform 7657 * @atomicservice 7658 * @since 12 7659 */ 7660 static genDHCommonParamsSpec(pLen: number, skLen?: number): DHCommonParamsSpec; 7661 } 7662 7663 /** 7664 * Specifies the ED25519 private key with its associated parameters. 7665 * 7666 * @typedef ED25519PriKeySpec 7667 * @extends AsyKeySpec 7668 * @syscap SystemCapability.Security.CryptoFramework 7669 * @crossplatform 7670 * @since 11 7671 */ 7672 /** 7673 * Specifies the ED25519 private key with its associated parameters. 7674 * To generate a key based on key parameters, pass it to createAsyKeyGeneratorBySpec to create a key generator. 7675 * 7676 * @typedef ED25519PriKeySpec 7677 * @extends AsyKeySpec 7678 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7679 * @crossplatform 7680 * @atomicservice 7681 * @since 12 7682 */ 7683 interface ED25519PriKeySpec extends AsyKeySpec { 7684 /** 7685 * Indicates the private value of the ED25519 private key. 7686 * 7687 * @type { bigint } 7688 * @syscap SystemCapability.Security.CryptoFramework 7689 * @crossplatform 7690 * @since 11 7691 */ 7692 /** 7693 * Indicates the private value of the ED25519 private key. 7694 * 7695 * @type { bigint } 7696 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7697 * @crossplatform 7698 * @atomicservice 7699 * @since 12 7700 */ 7701 sk: bigint; 7702 } 7703 7704 /** 7705 * Specifies the ED25519 public key with its associated parameters. 7706 * 7707 * @typedef ED25519PubKeySpec 7708 * @extends AsyKeySpec 7709 * @syscap SystemCapability.Security.CryptoFramework 7710 * @crossplatform 7711 * @since 11 7712 */ 7713 /** 7714 * Specifies the ED25519 public key with its associated parameters. 7715 * To generate a key based on key parameters, pass it to createAsyKeyGeneratorBySpec to create a key generator. 7716 * 7717 * @typedef ED25519PubKeySpec 7718 * @extends AsyKeySpec 7719 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7720 * @crossplatform 7721 * @atomicservice 7722 * @since 12 7723 */ 7724 interface ED25519PubKeySpec extends AsyKeySpec { 7725 /** 7726 * Indicates the public value of the ED25519 public key. 7727 * 7728 * @type { bigint } 7729 * @syscap SystemCapability.Security.CryptoFramework 7730 * @crossplatform 7731 * @since 11 7732 */ 7733 /** 7734 * Indicates the public value of the ED25519 public key. 7735 * 7736 * @type { bigint } 7737 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7738 * @crossplatform 7739 * @atomicservice 7740 * @since 12 7741 */ 7742 pk: bigint; 7743 } 7744 7745 /** 7746 * Specifies the ED25519 keypair with its associated parameters. 7747 * 7748 * @typedef ED25519KeyPairSpec 7749 * @extends AsyKeySpec 7750 * @syscap SystemCapability.Security.CryptoFramework 7751 * @crossplatform 7752 * @since 11 7753 */ 7754 /** 7755 * Specifies the ED25519 keypair with its associated parameters. 7756 * To generate a key based on key parameters, pass it to createAsyKeyGeneratorBySpec to create a key generator. 7757 * 7758 * @typedef ED25519KeyPairSpec 7759 * @extends AsyKeySpec 7760 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7761 * @crossplatform 7762 * @atomicservice 7763 * @since 12 7764 */ 7765 interface ED25519KeyPairSpec extends AsyKeySpec { 7766 /** 7767 * Indicates the private value of the ED25519 private key. 7768 * 7769 * @type { bigint } 7770 * @syscap SystemCapability.Security.CryptoFramework 7771 * @crossplatform 7772 * @since 11 7773 */ 7774 /** 7775 * Indicates the private value of the ED25519 private key. 7776 * 7777 * @type { bigint } 7778 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7779 * @crossplatform 7780 * @atomicservice 7781 * @since 12 7782 */ 7783 sk: bigint; 7784 7785 /** 7786 * Indicates the public value of the ED25519 public key. 7787 * 7788 * @type { bigint } 7789 * @syscap SystemCapability.Security.CryptoFramework 7790 * @crossplatform 7791 * @since 11 7792 */ 7793 /** 7794 * Indicates the public value of the ED25519 public key. 7795 * 7796 * @type { bigint } 7797 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7798 * @crossplatform 7799 * @atomicservice 7800 * @since 12 7801 */ 7802 pk: bigint; 7803 } 7804 7805 /** 7806 * Specifies the X25519 private key with its associated parameters. 7807 * 7808 * @typedef X25519PriKeySpec 7809 * @extends AsyKeySpec 7810 * @syscap SystemCapability.Security.CryptoFramework 7811 * @crossplatform 7812 * @since 11 7813 */ 7814 /** 7815 * Specifies the X25519 private key with its associated parameters. 7816 * To generate a key based on key parameters, pass it to createAsyKeyGeneratorBySpec to create a key generator. 7817 * 7818 * @typedef X25519PriKeySpec 7819 * @extends AsyKeySpec 7820 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7821 * @crossplatform 7822 * @atomicservice 7823 * @since 12 7824 */ 7825 interface X25519PriKeySpec extends AsyKeySpec { 7826 /** 7827 * Indicates the private value of the X25519 private key. 7828 * 7829 * @type { bigint } 7830 * @syscap SystemCapability.Security.CryptoFramework 7831 * @crossplatform 7832 * @since 11 7833 */ 7834 /** 7835 * Indicates the private value of the X25519 private key. 7836 * 7837 * @type { bigint } 7838 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7839 * @crossplatform 7840 * @atomicservice 7841 * @since 12 7842 */ 7843 sk: bigint; 7844 } 7845 7846 /** 7847 * Specifies the X25519 public key with its associated parameters. 7848 * 7849 * @typedef X25519PubKeySpec 7850 * @extends AsyKeySpec 7851 * @syscap SystemCapability.Security.CryptoFramework 7852 * @crossplatform 7853 * @since 11 7854 */ 7855 /** 7856 * Specifies the X25519 public key with its associated parameters. 7857 * To generate a key based on key parameters, pass it to createAsyKeyGeneratorBySpec to create a key generator. 7858 * 7859 * @typedef X25519PubKeySpec 7860 * @extends AsyKeySpec 7861 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7862 * @crossplatform 7863 * @atomicservice 7864 * @since 12 7865 */ 7866 interface X25519PubKeySpec extends AsyKeySpec { 7867 /** 7868 * Indicates the public value of the X25519 public key. 7869 * 7870 * @type { bigint } 7871 * @syscap SystemCapability.Security.CryptoFramework 7872 * @crossplatform 7873 * @since 11 7874 */ 7875 /** 7876 * Indicates the public value of the X25519 public key. 7877 * 7878 * @type { bigint } 7879 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7880 * @crossplatform 7881 * @atomicservice 7882 * @since 12 7883 */ 7884 pk: bigint; 7885 } 7886 7887 /** 7888 * Specifies the X25519 keypair with its associated parameters. 7889 * 7890 * @typedef X25519KeyPairSpec 7891 * @extends AsyKeySpec 7892 * @syscap SystemCapability.Security.CryptoFramework 7893 * @crossplatform 7894 * @since 11 7895 */ 7896 /** 7897 * Specifies the X25519 keypair with its associated parameters. 7898 * To generate a key based on key parameters, pass it to createAsyKeyGeneratorBySpec to create a key generator. 7899 * 7900 * @typedef X25519KeyPairSpec 7901 * @extends AsyKeySpec 7902 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7903 * @crossplatform 7904 * @atomicservice 7905 * @since 12 7906 */ 7907 interface X25519KeyPairSpec extends AsyKeySpec { 7908 /** 7909 * Indicates the private value of the X25519 private key. 7910 * 7911 * @type { bigint } 7912 * @syscap SystemCapability.Security.CryptoFramework 7913 * @crossplatform 7914 * @since 11 7915 */ 7916 /** 7917 * Indicates the private value of the X25519 private key. 7918 * 7919 * @type { bigint } 7920 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7921 * @crossplatform 7922 * @atomicservice 7923 * @since 12 7924 */ 7925 sk: bigint; 7926 7927 /** 7928 * Indicates the public value of the X25519 public key. 7929 * 7930 * @type { bigint } 7931 * @syscap SystemCapability.Security.CryptoFramework 7932 * @crossplatform 7933 * @since 11 7934 */ 7935 /** 7936 * Indicates the public value of the X25519 public key. 7937 * 7938 * @type { bigint } 7939 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7940 * @crossplatform 7941 * @atomicservice 7942 * @since 12 7943 */ 7944 pk: bigint; 7945 } 7946 7947 /** 7948 * Specifies the set of common parameters used in the RSA algorithm. 7949 * 7950 * @typedef RSACommonParamsSpec 7951 * @extends AsyKeySpec 7952 * @syscap SystemCapability.Security.CryptoFramework 7953 * @since 10 7954 */ 7955 /** 7956 * Specifies the set of common parameters used in the RSA algorithm. 7957 * 7958 * @typedef RSACommonParamsSpec 7959 * @extends AsyKeySpec 7960 * @syscap SystemCapability.Security.CryptoFramework 7961 * @crossplatform 7962 * @since 11 7963 */ 7964 /** 7965 * Specifies the set of common parameters used in the RSA algorithm. 7966 * To generate a key based on key parameters, pass it to createAsyKeyGeneratorBySpec to create a key generator. 7967 * 7968 * @typedef RSACommonParamsSpec 7969 * @extends AsyKeySpec 7970 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7971 * @crossplatform 7972 * @atomicservice 7973 * @since 12 7974 */ 7975 interface RSACommonParamsSpec extends AsyKeySpec { 7976 /** 7977 * Indicates the modulus n. 7978 * 7979 * @type { bigint } 7980 * @syscap SystemCapability.Security.CryptoFramework 7981 * @since 10 7982 */ 7983 /** 7984 * Indicates the modulus n. 7985 * 7986 * @type { bigint } 7987 * @syscap SystemCapability.Security.CryptoFramework 7988 * @crossplatform 7989 * @since 11 7990 */ 7991 /** 7992 * Indicates the modulus n. 7993 * 7994 * @type { bigint } 7995 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 7996 * @crossplatform 7997 * @atomicservice 7998 * @since 12 7999 */ 8000 n: bigint; 8001 } 8002 8003 /** 8004 * Specifies the RSA public key with its associated parameters. 8005 * 8006 * @typedef RSAPubKeySpec 8007 * @extends AsyKeySpec 8008 * @syscap SystemCapability.Security.CryptoFramework 8009 * @since 10 8010 */ 8011 /** 8012 * Specifies the RSA public key with its associated parameters. 8013 * 8014 * @typedef RSAPubKeySpec 8015 * @extends AsyKeySpec 8016 * @syscap SystemCapability.Security.CryptoFramework 8017 * @crossplatform 8018 * @since 11 8019 */ 8020 /** 8021 * Specifies the RSA public key with its associated parameters. 8022 * To generate a key based on key parameters, pass it to createAsyKeyGeneratorBySpec to create a key generator. 8023 * 8024 * @typedef RSAPubKeySpec 8025 * @extends AsyKeySpec 8026 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 8027 * @crossplatform 8028 * @atomicservice 8029 * @since 12 8030 */ 8031 interface RSAPubKeySpec extends AsyKeySpec { 8032 /** 8033 * Indicates the RSA common parameters. 8034 * 8035 * @type { RSACommonParamsSpec } 8036 * @syscap SystemCapability.Security.CryptoFramework 8037 * @since 10 8038 */ 8039 /** 8040 * Indicates the RSA common parameters. 8041 * 8042 * @type { RSACommonParamsSpec } 8043 * @syscap SystemCapability.Security.CryptoFramework 8044 * @crossplatform 8045 * @since 11 8046 */ 8047 /** 8048 * Indicates the RSA common parameters. 8049 * 8050 * @type { RSACommonParamsSpec } 8051 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 8052 * @crossplatform 8053 * @atomicservice 8054 * @since 12 8055 */ 8056 params: RSACommonParamsSpec; 8057 8058 /** 8059 * Indicates the public exponent e. 8060 * 8061 * @type { bigint } 8062 * @syscap SystemCapability.Security.CryptoFramework 8063 * @since 10 8064 */ 8065 /** 8066 * Indicates the public exponent e. 8067 * 8068 * @type { bigint } 8069 * @syscap SystemCapability.Security.CryptoFramework 8070 * @crossplatform 8071 * @since 11 8072 */ 8073 /** 8074 * Indicates the public exponent e. 8075 * 8076 * @type { bigint } 8077 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 8078 * @crossplatform 8079 * @atomicservice 8080 * @since 12 8081 */ 8082 pk: bigint; 8083 } 8084 8085 /** 8086 * Specifies the RSA keypair with its associated parameters. 8087 * 8088 * @typedef RSAKeyPairSpec 8089 * @extends AsyKeySpec 8090 * @syscap SystemCapability.Security.CryptoFramework 8091 * @since 10 8092 */ 8093 /** 8094 * Specifies the RSA keypair with its associated parameters. 8095 * 8096 * @typedef RSAKeyPairSpec 8097 * @extends AsyKeySpec 8098 * @syscap SystemCapability.Security.CryptoFramework 8099 * @crossplatform 8100 * @since 11 8101 */ 8102 /** 8103 * Specifies the RSA keypair with its associated parameters. 8104 * To generate a key based on key parameters, pass it to createAsyKeyGeneratorBySpec to create a key generator. 8105 * 8106 * @typedef RSAKeyPairSpec 8107 * @extends AsyKeySpec 8108 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 8109 * @crossplatform 8110 * @atomicservice 8111 * @since 12 8112 */ 8113 interface RSAKeyPairSpec extends AsyKeySpec { 8114 /** 8115 * Indicates the RSA common parameters. 8116 * 8117 * @type { RSACommonParamsSpec } 8118 * @syscap SystemCapability.Security.CryptoFramework 8119 * @since 10 8120 */ 8121 /** 8122 * Indicates the RSA common parameters. 8123 * 8124 * @type { RSACommonParamsSpec } 8125 * @syscap SystemCapability.Security.CryptoFramework 8126 * @crossplatform 8127 * @since 11 8128 */ 8129 /** 8130 * Indicates the RSA common parameters. 8131 * 8132 * @type { RSACommonParamsSpec } 8133 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 8134 * @crossplatform 8135 * @atomicservice 8136 * @since 12 8137 */ 8138 params: RSACommonParamsSpec; 8139 8140 /** 8141 * Indicates the private exponent d. 8142 * 8143 * @type { bigint } 8144 * @syscap SystemCapability.Security.CryptoFramework 8145 * @since 10 8146 */ 8147 /** 8148 * Indicates the private exponent d. 8149 * 8150 * @type { bigint } 8151 * @syscap SystemCapability.Security.CryptoFramework 8152 * @crossplatform 8153 * @since 11 8154 */ 8155 /** 8156 * Indicates the private exponent d. 8157 * 8158 * @type { bigint } 8159 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 8160 * @crossplatform 8161 * @atomicservice 8162 * @since 12 8163 */ 8164 sk: bigint; 8165 8166 /** 8167 * Indicates the public exponent e. 8168 * 8169 * @type { bigint } 8170 * @syscap SystemCapability.Security.CryptoFramework 8171 * @since 10 8172 */ 8173 /** 8174 * Indicates the public exponent e. 8175 * 8176 * @type { bigint } 8177 * @syscap SystemCapability.Security.CryptoFramework 8178 * @crossplatform 8179 * @since 11 8180 */ 8181 /** 8182 * Indicates the public exponent e. 8183 * 8184 * @type { bigint } 8185 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 8186 * @crossplatform 8187 * @atomicservice 8188 * @since 12 8189 */ 8190 pk: bigint; 8191 } 8192 8193 /** 8194 * The AsyKeyGeneratorBySpec provides the ability to generate key with its associated parameters. 8195 * 8196 * @typedef AsyKeyGeneratorBySpec 8197 * @syscap SystemCapability.Security.CryptoFramework 8198 * @since 10 8199 */ 8200 /** 8201 * The AsyKeyGeneratorBySpec provides the ability to generate key with its associated parameters. 8202 * 8203 * @typedef AsyKeyGeneratorBySpec 8204 * @syscap SystemCapability.Security.CryptoFramework 8205 * @crossplatform 8206 * @since 11 8207 */ 8208 /** 8209 * The AsyKeyGeneratorBySpec provides the ability to generate key with its associated parameters. 8210 * Before using the APIs of this class, you need to use createAsyKeyGeneratorBySpec to create an AsyKeyGeneratorBySpec instance. 8211 * 8212 * @typedef AsyKeyGeneratorBySpec 8213 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 8214 * @crossplatform 8215 * @atomicservice 8216 * @since 12 8217 */ 8218 interface AsyKeyGeneratorBySpec { 8219 /** 8220 * Generate an asymmetric keypair. 8221 * 8222 * @param { AsyncCallback<KeyPair> } callback - the callback used to return keypair. 8223 * @throws { BusinessError } 401 - invalid parameters. Possible causes: Incorrect parameter types; 8224 * @throws { BusinessError } 17620001 - memory operation failed. 8225 * @throws { BusinessError } 17630001 - crypto operation error. 8226 * @syscap SystemCapability.Security.CryptoFramework 8227 * @since 10 8228 */ 8229 /** 8230 * Generate an asymmetric keypair. 8231 * 8232 * @param { AsyncCallback<KeyPair> } callback - the callback used to return keypair. 8233 * @throws { BusinessError } 401 - invalid parameters. Possible causes: Incorrect parameter types; 8234 * @throws { BusinessError } 17620001 - memory operation failed. 8235 * @throws { BusinessError } 17630001 - crypto operation error. 8236 * @syscap SystemCapability.Security.CryptoFramework 8237 * @crossplatform 8238 * @since 11 8239 */ 8240 /** 8241 * Generate an asymmetric keypair. 8242 * 8243 * @param { AsyncCallback<KeyPair> } callback - the callback used to return keypair. 8244 * @throws { BusinessError } 401 - invalid parameters. Possible causes: Incorrect parameter types; 8245 * @throws { BusinessError } 17620001 - memory operation failed. 8246 * @throws { BusinessError } 17630001 - crypto operation error. 8247 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 8248 * @crossplatform 8249 * @atomicservice 8250 * @since 12 8251 */ 8252 generateKeyPair(callback: AsyncCallback<KeyPair>): void; 8253 8254 /** 8255 * Generate an asymmetric keypair. 8256 * 8257 * @returns { Promise<KeyPair> } the promise used to return keypair. 8258 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8259 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8260 * @throws { BusinessError } 17620001 - memory operation failed. 8261 * @throws { BusinessError } 17630001 - crypto operation error. 8262 * @syscap SystemCapability.Security.CryptoFramework 8263 * @since 10 8264 */ 8265 /** 8266 * Generate an asymmetric keypair. 8267 * 8268 * @returns { Promise<KeyPair> } the promise used to return keypair. 8269 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8270 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8271 * @throws { BusinessError } 17620001 - memory operation failed. 8272 * @throws { BusinessError } 17630001 - crypto operation error. 8273 * @syscap SystemCapability.Security.CryptoFramework 8274 * @crossplatform 8275 * @since 11 8276 */ 8277 /** 8278 * Generate an asymmetric keypair. 8279 * 8280 * @returns { Promise<KeyPair> } the promise used to return keypair. 8281 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8282 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8283 * @throws { BusinessError } 17620001 - memory operation failed. 8284 * @throws { BusinessError } 17630001 - crypto operation error. 8285 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 8286 * @crossplatform 8287 * @atomicservice 8288 * @since 12 8289 */ 8290 generateKeyPair(): Promise<KeyPair>; 8291 8292 /** 8293 * Generate an asymmetric keypair. 8294 * 8295 * @returns { KeyPair } return keypair. 8296 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8297 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8298 * @throws { BusinessError } 17620001 - memory operation failed. 8299 * @throws { BusinessError } 17630001 - crypto operation error. 8300 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 8301 * @crossplatform 8302 * @atomicservice 8303 * @since 12 8304 */ 8305 generateKeyPairSync(): KeyPair; 8306 8307 /** 8308 * Generate a private key instance. 8309 * 8310 * @param { AsyncCallback<PriKey> } callback - the callback used to return PriKey. 8311 * @throws { BusinessError } 401 - invalid parameters. Possible causes: Mandatory parameters are left unspecified; 8312 * @throws { BusinessError } 17620001 - memory operation failed. 8313 * @throws { BusinessError } 17630001 - crypto operation error. 8314 * @syscap SystemCapability.Security.CryptoFramework 8315 * @since 10 8316 */ 8317 /** 8318 * Generate a private key instance. 8319 * 8320 * @param { AsyncCallback<PriKey> } callback - the callback used to return PriKey. 8321 * @throws { BusinessError } 401 - invalid parameters. Possible causes: Mandatory parameters are left unspecified; 8322 * @throws { BusinessError } 17620001 - memory operation failed. 8323 * @throws { BusinessError } 17630001 - crypto operation error. 8324 * @syscap SystemCapability.Security.CryptoFramework 8325 * @crossplatform 8326 * @since 11 8327 */ 8328 /** 8329 * Generate a private key instance. 8330 * 8331 * @param { AsyncCallback<PriKey> } callback - the callback used to return PriKey. 8332 * @throws { BusinessError } 401 - invalid parameters. Possible causes: Mandatory parameters are left unspecified; 8333 * @throws { BusinessError } 17620001 - memory operation failed. 8334 * @throws { BusinessError } 17630001 - crypto operation error. 8335 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 8336 * @crossplatform 8337 * @atomicservice 8338 * @since 12 8339 */ 8340 generatePriKey(callback: AsyncCallback<PriKey>): void; 8341 8342 /** 8343 * Generate a private key instance. 8344 * 8345 * @returns { Promise<PriKey> } the promise used to return PriKey. 8346 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8347 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8348 * @throws { BusinessError } 17620001 - memory operation failed. 8349 * @throws { BusinessError } 17630001 - crypto operation error. 8350 * @syscap SystemCapability.Security.CryptoFramework 8351 * @since 10 8352 */ 8353 /** 8354 * Generate a private key instance. 8355 * 8356 * @returns { Promise<PriKey> } the promise used to return PriKey. 8357 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8358 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8359 * @throws { BusinessError } 17620001 - memory operation failed. 8360 * @throws { BusinessError } 17630001 - crypto operation error. 8361 * @syscap SystemCapability.Security.CryptoFramework 8362 * @crossplatform 8363 * @since 11 8364 */ 8365 /** 8366 * Generate a private key instance. 8367 * 8368 * @returns { Promise<PriKey> } the promise used to return PriKey. 8369 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8370 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8371 * @throws { BusinessError } 17620001 - memory operation failed. 8372 * @throws { BusinessError } 17630001 - crypto operation error. 8373 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 8374 * @crossplatform 8375 * @atomicservice 8376 * @since 12 8377 */ 8378 generatePriKey(): Promise<PriKey>; 8379 8380 /** 8381 * Generate a private key instance. 8382 * 8383 * @returns { PriKey } return PriKey. 8384 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8385 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8386 * @throws { BusinessError } 17620001 - memory operation failed. 8387 * @throws { BusinessError } 17630001 - crypto operation error. 8388 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 8389 * @crossplatform 8390 * @atomicservice 8391 * @since 12 8392 */ 8393 generatePriKeySync(): PriKey; 8394 8395 /** 8396 * Generate a public key instance. 8397 * 8398 * @param { AsyncCallback<PubKey> } callback - the callback used to return PubKey. 8399 * @throws { BusinessError } 401 - invalid parameters. Possible causes: Incorrect parameter types; 8400 * @throws { BusinessError } 17620001 - memory operation failed. 8401 * @throws { BusinessError } 17630001 - crypto operation error. 8402 * @syscap SystemCapability.Security.CryptoFramework 8403 * @since 10 8404 */ 8405 /** 8406 * Generate a public key instance. 8407 * 8408 * @param { AsyncCallback<PubKey> } callback - the callback used to return PubKey. 8409 * @throws { BusinessError } 401 - invalid parameters. Possible causes: Incorrect parameter types; 8410 * @throws { BusinessError } 17620001 - memory operation failed. 8411 * @throws { BusinessError } 17630001 - crypto operation error. 8412 * @syscap SystemCapability.Security.CryptoFramework 8413 * @crossplatform 8414 * @since 11 8415 */ 8416 /** 8417 * Generate a public key instance. 8418 * 8419 * @param { AsyncCallback<PubKey> } callback - the callback used to return PubKey. 8420 * @throws { BusinessError } 401 - invalid parameters. Possible causes: Incorrect parameter types; 8421 * @throws { BusinessError } 17620001 - memory operation failed. 8422 * @throws { BusinessError } 17630001 - crypto operation error. 8423 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 8424 * @crossplatform 8425 * @atomicservice 8426 * @since 12 8427 */ 8428 generatePubKey(callback: AsyncCallback<PubKey>): void; 8429 8430 /** 8431 * Generate a public key instance. 8432 * 8433 * @returns { Promise<PubKey> } the promise used to return PubKey. 8434 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8435 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8436 * @throws { BusinessError } 17620001 - memory operation failed. 8437 * @throws { BusinessError } 17630001 - crypto operation error. 8438 * @syscap SystemCapability.Security.CryptoFramework 8439 * @since 10 8440 */ 8441 /** 8442 * Generate a public key instance. 8443 * 8444 * @returns { Promise<PubKey> } the promise used to return PubKey. 8445 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8446 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8447 * @throws { BusinessError } 17620001 - memory operation failed. 8448 * @throws { BusinessError } 17630001 - crypto operation error. 8449 * @syscap SystemCapability.Security.CryptoFramework 8450 * @crossplatform 8451 * @since 11 8452 */ 8453 /** 8454 * Generate a public key instance. 8455 * 8456 * @returns { Promise<PubKey> } the promise used to return PubKey. 8457 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8458 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8459 * @throws { BusinessError } 17620001 - memory operation failed. 8460 * @throws { BusinessError } 17630001 - crypto operation error. 8461 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 8462 * @crossplatform 8463 * @atomicservice 8464 * @since 12 8465 */ 8466 generatePubKey(): Promise<PubKey>; 8467 8468 /** 8469 * Generate a public key instance. 8470 * 8471 * @returns { PubKey } return PubKey. 8472 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8473 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8474 * @throws { BusinessError } 17620001 - memory operation failed. 8475 * @throws { BusinessError } 17630001 - crypto operation error. 8476 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 8477 * @crossplatform 8478 * @atomicservice 8479 * @since 12 8480 */ 8481 generatePubKeySync(): PubKey; 8482 8483 /** 8484 * Indicates the algorithm name of the generator. 8485 * 8486 * @type { string } 8487 * @readonly 8488 * @syscap SystemCapability.Security.CryptoFramework 8489 * @since 10 8490 */ 8491 /** 8492 * Indicates the algorithm name of the generator. 8493 * 8494 * @type { string } 8495 * @readonly 8496 * @syscap SystemCapability.Security.CryptoFramework 8497 * @crossplatform 8498 * @since 11 8499 */ 8500 /** 8501 * Indicates the algorithm name of the generator. 8502 * 8503 * @type { string } 8504 * @readonly 8505 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 8506 * @crossplatform 8507 * @atomicservice 8508 * @since 12 8509 */ 8510 readonly algName: string; 8511 } 8512 8513 /** 8514 * Create an asymmetric key generator with the specified parameters. 8515 * 8516 * @param { AsyKeySpec } asyKeySpec - indicates the associated parameters of algorithm. 8517 * @returns { AsyKeyGeneratorBySpec } the generator obj create by asyKeySpec. 8518 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8519 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8520 * @throws { BusinessError } 801 - this operation is not supported. 8521 * @throws { BusinessError } 17620001 - memory operation failed. 8522 * @syscap SystemCapability.Security.CryptoFramework 8523 * @since 10 8524 */ 8525 /** 8526 * Create an asymmetric key generator with the specified parameters. 8527 * 8528 * @param { AsyKeySpec } asyKeySpec - indicates the associated parameters of algorithm. 8529 * @returns { AsyKeyGeneratorBySpec } the generator obj create by asyKeySpec. 8530 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8531 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8532 * @throws { BusinessError } 801 - this operation is not supported. 8533 * @throws { BusinessError } 17620001 - memory operation failed. 8534 * @syscap SystemCapability.Security.CryptoFramework 8535 * @crossplatform 8536 * @since 11 8537 */ 8538 /** 8539 * Create an asymmetric key generator with the specified parameters. 8540 * 8541 * @param { AsyKeySpec } asyKeySpec - indicates the associated parameters of algorithm. 8542 * @returns { AsyKeyGeneratorBySpec } the generator obj create by asyKeySpec. 8543 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8544 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8545 * @throws { BusinessError } 801 - this operation is not supported. 8546 * @throws { BusinessError } 17620001 - memory operation failed. 8547 * @syscap SystemCapability.Security.CryptoFramework.Key.AsymKey 8548 * @crossplatform 8549 * @atomicservice 8550 * @since 12 8551 */ 8552 function createAsyKeyGeneratorBySpec(asyKeySpec: AsyKeySpec): AsyKeyGeneratorBySpec; 8553 8554 /** 8555 * Specifies the key derivation function parameters. 8556 * 8557 * @typedef KdfSpec 8558 * @syscap SystemCapability.Security.CryptoFramework 8559 * @crossplatform 8560 * @since 11 8561 */ 8562 /** 8563 * Specifies the key derivation function parameters. 8564 * When the key derivation function is used to derive a key, you need to construct and pass in a child class object of KdfSpec. 8565 * 8566 * @typedef KdfSpec 8567 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8568 * @crossplatform 8569 * @atomicservice 8570 * @since 12 8571 */ 8572 interface KdfSpec { 8573 /** 8574 * Indicates the algorithm name of key derivation function. 8575 * 8576 * @type { string } 8577 * @syscap SystemCapability.Security.CryptoFramework 8578 * @crossplatform 8579 * @since 11 8580 */ 8581 /** 8582 * Indicates the algorithm name of key derivation function. 8583 * 8584 * @type { string } 8585 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8586 * @crossplatform 8587 * @atomicservice 8588 * @since 12 8589 */ 8590 algName: string; 8591 } 8592 8593 /** 8594 * Specifies the PBKDF2 parameters. 8595 * 8596 * @typedef PBKDF2Spec 8597 * @extends KdfSpec 8598 * @syscap SystemCapability.Security.CryptoFramework 8599 * @crossplatform 8600 * @since 11 8601 */ 8602 /** 8603 * Specifies the PBKDF2 parameters. 8604 * 8605 * @typedef PBKDF2Spec 8606 * @extends KdfSpec 8607 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8608 * @crossplatform 8609 * @atomicservice 8610 * @since 12 8611 */ 8612 interface PBKDF2Spec extends KdfSpec { 8613 /** 8614 * Indicates the password parameter of PBKDF2. 8615 * 8616 * @type { string | Uint8Array } 8617 * @syscap SystemCapability.Security.CryptoFramework 8618 * @crossplatform 8619 * @since 11 8620 */ 8621 /** 8622 * Indicates the password parameter of PBKDF2. 8623 * 8624 * @type { string | Uint8Array } 8625 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8626 * @crossplatform 8627 * @atomicservice 8628 * @since 12 8629 */ 8630 password: string | Uint8Array; 8631 8632 /** 8633 * Indicates the salt parameter of PBKDF2. 8634 * 8635 * @type { Uint8Array } 8636 * @syscap SystemCapability.Security.CryptoFramework 8637 * @crossplatform 8638 * @since 11 8639 */ 8640 /** 8641 * Indicates the salt parameter of PBKDF2. 8642 * 8643 * @type { Uint8Array } 8644 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8645 * @crossplatform 8646 * @atomicservice 8647 * @since 12 8648 */ 8649 salt: Uint8Array; 8650 8651 /** 8652 * Indicates the iteration number of PBKDF2. 8653 * 8654 * @type { number } 8655 * @syscap SystemCapability.Security.CryptoFramework 8656 * @crossplatform 8657 * @since 11 8658 */ 8659 /** 8660 * Indicates the iteration number of PBKDF2. 8661 * 8662 * @type { number } 8663 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8664 * @crossplatform 8665 * @atomicservice 8666 * @since 12 8667 */ 8668 iterations: number; 8669 8670 /** 8671 * Indicates the byte length of output key of PBKDF2. 8672 * 8673 * @type { number } 8674 * @syscap SystemCapability.Security.CryptoFramework 8675 * @crossplatform 8676 * @since 11 8677 */ 8678 /** 8679 * Indicates the byte length of output key of PBKDF2. 8680 * 8681 * @type { number } 8682 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8683 * @crossplatform 8684 * @atomicservice 8685 * @since 12 8686 */ 8687 keySize: number; 8688 } 8689 8690 /** 8691 * Specifies the HKDF parameters. 8692 * 8693 * @typedef HKDFSpec 8694 * @extends KdfSpec 8695 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8696 * @crossplatform 8697 * @atomicservice 8698 * @since 12 8699 */ 8700 interface HKDFSpec extends KdfSpec { 8701 /** 8702 * Indicates the key parameter of HKDF. 8703 * 8704 * @type { string | Uint8Array } 8705 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8706 * @crossplatform 8707 * @atomicservice 8708 * @since 12 8709 */ 8710 key: string | Uint8Array; 8711 8712 /** 8713 * Indicates the salt parameter of HKDF. 8714 * 8715 * @type { Uint8Array } 8716 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8717 * @crossplatform 8718 * @atomicservice 8719 * @since 12 8720 */ 8721 salt: Uint8Array; 8722 8723 /** 8724 * Indicates the info about the context of HKDF. 8725 * 8726 * @type { Uint8Array } 8727 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8728 * @crossplatform 8729 * @atomicservice 8730 * @since 12 8731 */ 8732 info: Uint8Array; 8733 8734 /** 8735 * Indicates the byte length of output key of HKDF. 8736 * 8737 * @type { number } 8738 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8739 * @crossplatform 8740 * @atomicservice 8741 * @since 12 8742 */ 8743 keySize: number; 8744 } 8745 8746 /** 8747 * Specifies the SCRYPT parameters. 8748 * 8749 * @extends KdfSpec 8750 * @typedef ScryptSpec 8751 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8752 * @crossplatform 8753 * @atomicservice 8754 * @since 18 8755 */ 8756 interface ScryptSpec extends KdfSpec { 8757 /** 8758 * Indicates the passphrase parameter of SCRYPT. 8759 * 8760 * @type { string | Uint8Array } 8761 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8762 * @crossplatform 8763 * @atomicservice 8764 * @since 18 8765 */ 8766 passphrase: string | Uint8Array; 8767 8768 /** 8769 * Indicates the salt parameter of SCRYPT. 8770 * 8771 * @type { Uint8Array } 8772 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8773 * @crossplatform 8774 * @atomicservice 8775 * @since 18 8776 */ 8777 salt: Uint8Array; 8778 8779 /** 8780 * Indicates the cost parameter of SCRYPT. 8781 * 8782 * @type { number } 8783 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8784 * @crossplatform 8785 * @atomicservice 8786 * @since 18 8787 */ 8788 n: number; 8789 8790 /** 8791 * Indicates the block size parameter of SCRYPT. 8792 * 8793 * @type { number } 8794 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8795 * @crossplatform 8796 * @atomicservice 8797 * @since 18 8798 */ 8799 r: number; 8800 8801 /** 8802 * Indicates the parallelization parameter of SCRYPT. 8803 * 8804 * @type { number } 8805 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8806 * @crossplatform 8807 * @atomicservice 8808 * @since 18 8809 */ 8810 p: number; 8811 8812 /** 8813 * Indicates the byte length of memory of SCRYPT. 8814 * 8815 * @type { number } 8816 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8817 * @crossplatform 8818 * @atomicservice 8819 * @since 18 8820 */ 8821 maxMemory: number; 8822 8823 /** 8824 * Indicates the byte length of output key of SCRYPT. 8825 * 8826 * @type { number } 8827 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8828 * @crossplatform 8829 * @atomicservice 8830 * @since 18 8831 */ 8832 keySize: number; 8833 } 8834 8835 /** 8836 * The key derivation function object provides the ability to derive key with its associated parameters. 8837 * 8838 * @typedef Kdf 8839 * @syscap SystemCapability.Security.CryptoFramework 8840 * @crossplatform 8841 * @since 11 8842 */ 8843 /** 8844 * The key derivation function object provides the ability to derive key with its associated parameters. 8845 * Before using APIs of this class, you need to create an instance of this class by using createKdf. 8846 * 8847 * @typedef Kdf 8848 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8849 * @crossplatform 8850 * @atomicservice 8851 * @since 12 8852 */ 8853 interface Kdf { 8854 /** 8855 * Generate a dataBlob object of secret key. 8856 * 8857 * @param { KdfSpec } params - the input params of key derivation function. 8858 * @param { AsyncCallback<DataBlob> } callback - the callback used to return dataBlob. 8859 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8860 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8861 * @throws { BusinessError } 17620001 - memory operation failed. 8862 * @throws { BusinessError } 17630001 - crypto operation error. 8863 * @syscap SystemCapability.Security.CryptoFramework 8864 * @crossplatform 8865 * @since 11 8866 */ 8867 /** 8868 * Generate a dataBlob object of secret key. 8869 * 8870 * @param { KdfSpec } params - the input params of key derivation function. 8871 * @param { AsyncCallback<DataBlob> } callback - the callback used to return dataBlob. 8872 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8873 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8874 * @throws { BusinessError } 17620001 - memory operation failed. 8875 * @throws { BusinessError } 17630001 - crypto operation error. 8876 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8877 * @crossplatform 8878 * @atomicservice 8879 * @since 12 8880 */ 8881 generateSecret(params: KdfSpec, callback: AsyncCallback<DataBlob>): void; 8882 8883 /** 8884 * Generate a dataBlob object of secret key. 8885 * 8886 * @param { KdfSpec } params - the input params of key derivation function. 8887 * @returns { Promise<DataBlob> } the promise used to return dataBlob. 8888 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8889 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8890 * @throws { BusinessError } 17620001 - memory operation failed. 8891 * @throws { BusinessError } 17630001 - crypto operation error. 8892 * @syscap SystemCapability.Security.CryptoFramework 8893 * @crossplatform 8894 * @since 11 8895 */ 8896 /** 8897 * Generate a dataBlob object of secret key. 8898 * 8899 * @param { KdfSpec } params - the input params of key derivation function. 8900 * @returns { Promise<DataBlob> } the promise used to return dataBlob. 8901 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8902 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8903 * @throws { BusinessError } 17620001 - memory operation failed. 8904 * @throws { BusinessError } 17630001 - crypto operation error. 8905 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8906 * @crossplatform 8907 * @atomicservice 8908 * @since 12 8909 */ 8910 generateSecret(params: KdfSpec): Promise<DataBlob>; 8911 8912 /** 8913 * Generate a dataBlob object of secret key. 8914 * 8915 * @param { KdfSpec } params - the input params of key derivation function. 8916 * @returns { DataBlob } the sync used to return dataBlob. 8917 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8918 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8919 * @throws { BusinessError } 17620001 - memory operation failed. 8920 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 8921 * @throws { BusinessError } 17630001 - crypto operation error. 8922 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8923 * @crossplatform 8924 * @atomicservice 8925 * @since 12 8926 */ 8927 generateSecretSync(params: KdfSpec): DataBlob; 8928 8929 /** 8930 * Indicates the algorithm name of the key derivation function. 8931 * 8932 * @type { string } 8933 * @readonly 8934 * @syscap SystemCapability.Security.CryptoFramework 8935 * @crossplatform 8936 * @since 11 8937 */ 8938 /** 8939 * Indicates the algorithm name of the key derivation function. 8940 * 8941 * @type { string } 8942 * @readonly 8943 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8944 * @crossplatform 8945 * @atomicservice 8946 * @since 12 8947 */ 8948 readonly algName: string; 8949 } 8950 8951 /** 8952 * Create a key derivation function object. 8953 * 8954 * @param { string } algName - indicates the algorithm name and params. 8955 * @returns { Kdf } the key derivation function object. 8956 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8957 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8958 * @throws { BusinessError } 801 - this operation is not supported. 8959 * @throws { BusinessError } 17620001 - memory operation failed. 8960 * @syscap SystemCapability.Security.CryptoFramework 8961 * @crossplatform 8962 * @since 11 8963 */ 8964 /** 8965 * Create a key derivation function object. 8966 * 8967 * @param { string } algName - indicates the algorithm name and params. Multiple parameters need to be concatenated by "|". 8968 * @returns { Kdf } the key derivation function object. 8969 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 8970 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 8971 * @throws { BusinessError } 801 - this operation is not supported. 8972 * @throws { BusinessError } 17620001 - memory operation failed. 8973 * @syscap SystemCapability.Security.CryptoFramework.Kdf 8974 * @crossplatform 8975 * @atomicservice 8976 * @since 12 8977 */ 8978 function createKdf(algName: string): Kdf; 8979 8980 /** 8981 * Provides the interface for specifying detailed data in the SM2 ciphertext in ASN.1 format. 8982 * 8983 * @typedef SM2CipherTextSpec 8984 * @syscap SystemCapability.Security.CryptoFramework.Cipher 8985 * @crossplatform 8986 * @atomicservice 8987 * @since 12 8988 */ 8989 interface SM2CipherTextSpec { 8990 /** 8991 * Indicates the x coordinate, also known as C1x. 8992 * 8993 * @type { bigint } 8994 * @syscap SystemCapability.Security.CryptoFramework.Cipher 8995 * @crossplatform 8996 * @atomicservice 8997 * @since 12 8998 */ 8999 xCoordinate: bigint; 9000 9001 /** 9002 * Indicates the y coordinate, also known as C1y. 9003 * 9004 * @type { bigint } 9005 * @syscap SystemCapability.Security.CryptoFramework.Cipher 9006 * @crossplatform 9007 * @atomicservice 9008 * @since 12 9009 */ 9010 yCoordinate: bigint; 9011 9012 /** 9013 * Indicates the detailed ciphertext data, also known as C2. 9014 * 9015 * @type { Uint8Array } 9016 * @syscap SystemCapability.Security.CryptoFramework.Cipher 9017 * @crossplatform 9018 * @atomicservice 9019 * @since 12 9020 */ 9021 cipherTextData: Uint8Array; 9022 9023 /** 9024 * Indicates the hash data, also known as C3. 9025 * 9026 * @type { Uint8Array } 9027 * @syscap SystemCapability.Security.CryptoFramework.Cipher 9028 * @crossplatform 9029 * @atomicservice 9030 * @since 12 9031 */ 9032 hashData: Uint8Array; 9033 } 9034 9035 /** 9036 * Utilities for SM2 crypto operations. 9037 * 9038 * @syscap SystemCapability.Security.CryptoFramework.Cipher 9039 * @crossplatform 9040 * @atomicservice 9041 * @since 12 9042 */ 9043 class SM2CryptoUtil { 9044 /** 9045 * Generate the SM2 ciphertext in ASN.1 format according to the specific data. 9046 * 9047 * @param { SM2CipherTextSpec } spec - indicates the specific data of SM2 ciphertext. 9048 * @param { string } [mode] - indicates the arrangement mode of the SM2 ciphertext. 9049 * @returns { DataBlob } the SM2 ciphertext in ASN.1 format. 9050 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 9051 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 9052 * @throws { BusinessError } 17620001 - memory operation failed. 9053 * @throws { BusinessError } 17630001 - crypto operation error. 9054 * @static 9055 * @syscap SystemCapability.Security.CryptoFramework.Cipher 9056 * @crossplatform 9057 * @atomicservice 9058 * @since 12 9059 */ 9060 static genCipherTextBySpec(spec: SM2CipherTextSpec, mode?: string): DataBlob; 9061 9062 /** 9063 * Get the specific data from the SM2 ciphertext in ASN.1 format. 9064 * 9065 * @param { DataBlob } cipherText - indicates the SM2 ciphertext in ASN.1 format. 9066 * @param { string } [mode] - indicates the arrangement mode of the SM2 ciphertext. 9067 * @returns { SM2CipherTextSpec } the specific data of SM2 ciphertext. 9068 * @throws { BusinessError } 401 - invalid parameters. Possible causes: 1. Mandatory parameters are left unspecified; 9069 * <br>2. Incorrect parameter types; 3. Parameter verification failed. 9070 * @throws { BusinessError } 17620001 - memory operation failed. 9071 * @throws { BusinessError } 17630001 - crypto operation error. 9072 * @static 9073 * @syscap SystemCapability.Security.CryptoFramework.Cipher 9074 * @crossplatform 9075 * @atomicservice 9076 * @since 12 9077 */ 9078 static getCipherTextSpec(cipherText: DataBlob, mode?: string): SM2CipherTextSpec; 9079 } 9080 9081 /** 9082 * Defines the ECC signature spec, also works with SM2 signature. 9083 * 9084 * @typedef EccSignatureSpec 9085 * @syscap SystemCapability.Security.CryptoFramework.Signature 9086 * @crossplatform 9087 * @atomicservice 9088 * @since 20 9089 */ 9090 9091 interface EccSignatureSpec { 9092 /** 9093 * Indicates the r value of the signature. 9094 * 9095 * @type { bigint } 9096 * @syscap SystemCapability.Security.CryptoFramework.Signature 9097 * @crossplatform 9098 * @atomicservice 9099 * @since 20 9100 */ 9101 r: bigint; 9102 9103 /** 9104 * Indicates the s value of the signature. 9105 * 9106 * @type { bigint } 9107 * @syscap SystemCapability.Security.CryptoFramework.Signature 9108 * @crossplatform 9109 * @atomicservice 9110 * @since 20 9111 */ 9112 s: bigint; 9113 } 9114 9115 /** 9116 * Utilities for signature operations. 9117 * 9118 * @syscap SystemCapability.Security.CryptoFramework.Signature 9119 * @crossplatform 9120 * @atomicservice 9121 * @since 20 9122 */ 9123 class SignatureUtils { 9124 /** 9125 * Generates the ECC signature spec from the ECC signature in DER format. 9126 * 9127 * @param { Uint8Array } data - indicates the signature in DER format. 9128 * @returns { EccSignatureSpec } the ECC signature spec. 9129 * @throws { BusinessError } 17620001 - memory operation failed. 9130 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 9131 * @throws { BusinessError } 17620003 - parameter check failed. Possible causes: 9132 * <br>1. The length of the data parameter is 0 or too large. 9133 * @throws { BusinessError } 17630001 - crypto operation error. 9134 * @static 9135 * @syscap SystemCapability.Security.CryptoFramework.Signature 9136 * @crossplatform 9137 * @atomicservice 9138 * @since 20 9139 */ 9140 static genEccSignatureSpec(data: Uint8Array): EccSignatureSpec; 9141 9142 /** 9143 * Generates the ECC signature in DER format according to the ECC signature spec. 9144 * 9145 * @param { EccSignatureSpec } spec - indicates the ECC signature spec. 9146 * @returns { Uint8Array } the signature in DER format. 9147 * @throws { BusinessError } 17620001 - memory operation failed. 9148 * @throws { BusinessError } 17620002 - failed to convert parameters between arkts and c. 9149 * @throws { BusinessError } 17620003 - parameter check failed. Possible causes: 9150 * <br>1. The r or s value of the spec parameter is 0 or too large. 9151 * @throws { BusinessError } 17630001 - crypto operation error. 9152 * @static 9153 * @syscap SystemCapability.Security.CryptoFramework.Signature 9154 * @crossplatform 9155 * @atomicservice 9156 * @since 20 9157 */ 9158 static genEccSignature(spec: EccSignatureSpec): Uint8Array; 9159 } 9160} 9161 9162export default cryptoFramework; 9163