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