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