1# crypto_signature.h 2 3<!--Kit: Crypto Architecture Kit--> 4<!--Subsystem: Security--> 5<!--Owner: @zxz--3--> 6<!--Designer: @lanming--> 7<!--Tester: @PAFT--> 8<!--Adviser: @zengyawen--> 9 10## Overview 11 12Defines APIs for signature verification. 13 14**Header file**: <CryptoArchitectureKit/crypto_signature.h> 15 16**Library**: libohcrypto.so 17 18**System capability**: SystemCapability.Security.CryptoFramework 19 20**Since**: 12 21 22**Related module**: [CryptoSignatureApi](capi-cryptosignatureapi.md) 23 24## Summary 25 26### Structs 27 28| Name| typedef Keyword| Description| 29| -- | -- | -- | 30| [OH_CryptoVerify](capi-cryptosignatureapi-oh-cryptoverify.md) | OH_CryptoVerify | Defines the data used for signature verification.| 31| [OH_CryptoSign](capi-cryptosignatureapi-oh-cryptosign.md) | OH_CryptoSign | Defines a struct for signing.| 32| [OH_CryptoEccSignatureSpec](capi-cryptosignatureapi-oh-cryptoeccsignaturespec.md) | OH_CryptoEccSignatureSpec | Defines a struct for ECC signing specifications.| 33 34### Enums 35 36| Name| typedef Keyword| Description| 37| -- | -- | -- | 38| [CryptoSignature_ParamType](#cryptosignature_paramtype) | CryptoSignature_ParamType | Enumerates the types of signature verification parameters.| 39 40### Functions 41 42| Name| Description| 43| -- | -- | 44| [OH_Crypto_ErrCode OH_CryptoVerify_Create(const char *algoName, OH_CryptoVerify **verify)](#oh_cryptoverify_create) | Creates a **Verify** instance for signature verification.| 45| [OH_Crypto_ErrCode OH_CryptoVerify_Init(OH_CryptoVerify *ctx, OH_CryptoPubKey *pubKey)](#oh_cryptoverify_init) | Initializes a **Verify** instance by using the public key.| 46| [OH_Crypto_ErrCode OH_CryptoVerify_Update(OH_CryptoVerify *ctx, Crypto_DataBlob *in)](#oh_cryptoverify_update) | Updates the data to be verified.| 47| [bool OH_CryptoVerify_Final(OH_CryptoVerify *ctx, Crypto_DataBlob *in, Crypto_DataBlob *signData)](#oh_cryptoverify_final) | Verifies the signature of the data.| 48| [OH_Crypto_ErrCode OH_CryptoVerify_Recover(OH_CryptoVerify *ctx, Crypto_DataBlob *signData,Crypto_DataBlob *rawSignData)](#oh_cryptoverify_recover) | Restores the raw signature data.| 49| [const char *OH_CryptoVerify_GetAlgoName(OH_CryptoVerify *ctx)](#oh_cryptoverify_getalgoname) | Obtains the signature verification algorithm.| 50| [OH_Crypto_ErrCode OH_CryptoVerify_SetParam(OH_CryptoVerify *ctx, CryptoSignature_ParamType type,Crypto_DataBlob *value)](#oh_cryptoverify_setparam) | Sets a signature verification parameter.| 51| [OH_Crypto_ErrCode OH_CryptoVerify_GetParam(OH_CryptoVerify *ctx, CryptoSignature_ParamType type,Crypto_DataBlob *value)](#oh_cryptoverify_getparam) | Obtains a signature verification parameter.| 52| [void OH_CryptoVerify_Destroy(OH_CryptoVerify *ctx)](#oh_cryptoverify_destroy) | Destroys a **Verify** instance.| 53| [OH_Crypto_ErrCode OH_CryptoSign_Create(const char *algoName, OH_CryptoSign **sign)](#oh_cryptosign_create) | Creates a signature instance based on the given algorithm name.| 54| [OH_Crypto_ErrCode OH_CryptoSign_Init(OH_CryptoSign *ctx, OH_CryptoPrivKey *privKey)](#oh_cryptosign_init) | Initializes a signature instance.| 55| [OH_Crypto_ErrCode OH_CryptoSign_Update(OH_CryptoSign *ctx, const Crypto_DataBlob *in)](#oh_cryptosign_update) | Updates the data to be signed.| 56| [OH_Crypto_ErrCode OH_CryptoSign_Final(OH_CryptoSign *ctx, const Crypto_DataBlob *in, Crypto_DataBlob *out)](#oh_cryptosign_final) | Finalizes the signing operation.| 57| [const char *OH_CryptoSign_GetAlgoName(OH_CryptoSign *ctx)](#oh_cryptosign_getalgoname) | Obtains the algorithm name of a signature instance.| 58| [OH_Crypto_ErrCode OH_CryptoSign_SetParam(OH_CryptoSign *ctx, CryptoSignature_ParamType type,const Crypto_DataBlob *value)](#oh_cryptosign_setparam) | Sets parameters for a signature instance.| 59| [OH_Crypto_ErrCode OH_CryptoSign_GetParam(OH_CryptoSign *ctx, CryptoSignature_ParamType type, Crypto_DataBlob *value)](#oh_cryptosign_getparam) | Obtains the specified parameter from a signature instance.| 60| [void OH_CryptoSign_Destroy(OH_CryptoSign *ctx)](#oh_cryptosign_destroy) | Destroys a signature instance.| 61| [OH_Crypto_ErrCode OH_CryptoEccSignatureSpec_Create(Crypto_DataBlob *eccSignature,OH_CryptoEccSignatureSpec **spec)](#oh_cryptoeccsignaturespec_create) | Creates ECC signing specifications.| 62| [OH_Crypto_ErrCode OH_CryptoEccSignatureSpec_GetRAndS(OH_CryptoEccSignatureSpec *spec, Crypto_DataBlob *r,Crypto_DataBlob *s)](#oh_cryptoeccsignaturespec_getrands) | Obtains the **r** and **s** values of an ECC signature.| 63| [OH_Crypto_ErrCode OH_CryptoEccSignatureSpec_SetRAndS(OH_CryptoEccSignatureSpec *spec, Crypto_DataBlob *r,Crypto_DataBlob *s)](#oh_cryptoeccsignaturespec_setrands) | Sets the **r** and **s** values of an ECC signature.| 64| [OH_Crypto_ErrCode OH_CryptoEccSignatureSpec_Encode(OH_CryptoEccSignatureSpec *spec, Crypto_DataBlob *out)](#oh_cryptoeccsignaturespec_encode) | Encodes ECC signing specifications into a signature in DER format.| 65| [void OH_CryptoEccSignatureSpec_Destroy(OH_CryptoEccSignatureSpec *spec)](#oh_cryptoeccsignaturespec_destroy) | Destroys ECC signing specifications.| 66 67## Enum Description 68 69### CryptoSignature_ParamType 70 71``` 72enum CryptoSignature_ParamType 73``` 74 75**Description** 76 77Enumerates the types of signature verification parameters. 78 79**Since**: 12 80 81| Enum Item| Description| 82| -- | -- | 83| CRYPTO_PSS_MD_NAME_STR = 100 | MD algorithm used with the PSS padding mode in RSA.| 84| CRYPTO_PSS_MGF_NAME_STR = 101 | Mask generation algorithm used with the PSS padding mode in RSA. Currently, only MGF1 is supported.| 85| CRYPTO_PSS_MGF1_NAME_STR = 102 | MD parameters for the MGF1 mask generation used with the PSS padding mode in RSA.| 86| CRYPTO_PSS_SALT_LEN_INT = 103 | Length of the salt in bytes used with the PSS padding mode in RSA.| 87| CRYPTO_PSS_TRAILER_FIELD_INT = 104 | Trailer field used in the encoding operation when PSS padding mode is used in RSA. The value is **1**.| 88| CRYPTO_SM2_USER_ID_DATABLOB = 105 | User ID field in SM2.| 89 90 91## Function Description 92 93### OH_CryptoVerify_Create() 94 95``` 96OH_Crypto_ErrCode OH_CryptoVerify_Create(const char *algoName, OH_CryptoVerify **verify) 97``` 98 99**Description** 100 101Creates a **Verify** instance for signature verification. 102 103**Since**: 12 104 105 106**Parameters** 107 108| Name| Description| 109| -- | -- | 110| const char *algoName | Pointer to the algorithm used to generate the **Verify** instance.<br> For example, **'RSA1024\|PKCS1\|SHA256'**.| | | 111| [OH_CryptoVerify](capi-cryptosignatureapi-oh-cryptoverify.md) **verify | Pointer to the **Verify** instance created.| 112 113**Returns** 114 115| Type| Description| 116| -- | -- | 117| [OH_Crypto_ErrCode](capi-crypto-common-h.md#oh_crypto_errcode) | **CRYPTO_SUCCESS**: The operation is successful.<br> **CRYPTO_INVALID_PARAMS**: A parameter is invalid.<br> **CRYPTO_NOT_SUPPORTED**: The operation is not supported.<br> **CRYPTO_MEMORY_ERROR**: A memory error occurs.<br> **CRYPTO_OPERATION_ERROR**: An error occurs when the API of a third-party algorithm library is called.| 118 119### OH_CryptoVerify_Init() 120 121``` 122OH_Crypto_ErrCode OH_CryptoVerify_Init(OH_CryptoVerify *ctx, OH_CryptoPubKey *pubKey) 123``` 124 125**Description** 126 127Initializes a **Verify** instance by using the public key. 128 129**Since**: 12 130 131 132**Parameters** 133 134| Name| Description| 135| -- | -- | 136| [OH_CryptoVerify](capi-cryptosignatureapi-oh-cryptoverify.md) *ctx | Pointer to the **Verify** instance.| 137| [OH_CryptoPubKey](capi-cryptoasymkeyapi-oh-cryptopubkey.md) *pubKey | Pointer to the public key.| 138 139**Returns** 140 141| Type| Description| 142| -- | -- | 143| [OH_Crypto_ErrCode](capi-crypto-common-h.md#oh_crypto_errcode) | **CRYPTO_SUCCESS**: The operation is successful.<br> **CRYPTO_INVALID_PARAMS**: A parameter is invalid.<br> **CRYPTO_NOT_SUPPORTED**: The operation is not supported.<br> **CRYPTO_MEMORY_ERROR**: A memory error occurs.<br> **CRYPTO_OPERATION_ERROR**: An error occurs when the API of a third-party algorithm library is called.| 144 145**Reference** 146 147[OH_CryptoVerify_Update](#oh_cryptoverify_update) 148 149[OH_CryptoVerify_Final](#oh_cryptoverify_final) 150 151 152### OH_CryptoVerify_Update() 153 154``` 155OH_Crypto_ErrCode OH_CryptoVerify_Update(OH_CryptoVerify *ctx, Crypto_DataBlob *in) 156``` 157 158**Description** 159 160Updates the data to be verified. 161 162**Since**: 12 163 164 165**Parameters** 166 167| Name| Description| 168| -- | -- | 169| [OH_CryptoVerify](capi-cryptosignatureapi-oh-cryptoverify.md) *ctx | Pointer to the **Verify** instance.| 170| [Crypto_DataBlob](capi-cryptocommonapi-crypto-datablob.md) *in | Pointer to the data to pass in.| 171 172**Returns** 173 174| Type| Description| 175| -- | -- | 176| [OH_Crypto_ErrCode](capi-crypto-common-h.md#oh_crypto_errcode) | **CRYPTO_SUCCESS**: The operation is successful.<br> **CRYPTO_INVALID_PARAMS**: A parameter is invalid.<br> **CRYPTO_NOT_SUPPORTED**: The operation is not supported.<br> **CRYPTO_MEMORY_ERROR**: A memory error occurs.<br> **CRYPTO_OPERATION_ERROR**: An error occurs when the API of a third-party algorithm library is called.| 177 178**Reference** 179 180[OH_CryptoVerify_Init](#oh_cryptoverify_init) 181 182[OH_CryptoVerify_Final](#oh_cryptoverify_final) 183 184 185### OH_CryptoVerify_Final() 186 187``` 188bool OH_CryptoVerify_Final(OH_CryptoVerify *ctx, Crypto_DataBlob *in, Crypto_DataBlob *signData) 189``` 190 191**Description** 192 193Verifies the signature of the data. 194 195**Since**: 12 196 197 198**Parameters** 199 200| Name| Description| 201| -- | -- | 202| [OH_CryptoVerify](capi-cryptosignatureapi-oh-cryptoverify.md) *ctx | Pointer to the **Verify** instance.| 203| [Crypto_DataBlob](capi-cryptocommonapi-crypto-datablob.md) *in | Pointer to the data passed in.| 204| [Crypto_DataBlob](capi-cryptocommonapi-crypto-datablob.md) *signData | Pointer to the signature data.| 205 206**Returns** 207 208| Type| Description| 209| -- | -- | 210| bool | Whether the signature verification is successful.| 211 212**Reference** 213 214[OH_CryptoVerify_Init](#oh_cryptoverify_init) 215 216[OH_CryptoVerify_Update](#oh_cryptoverify_update) 217 218 219### OH_CryptoVerify_Recover() 220 221``` 222OH_Crypto_ErrCode OH_CryptoVerify_Recover(OH_CryptoVerify *ctx, Crypto_DataBlob *signData,Crypto_DataBlob *rawSignData) 223``` 224 225**Description** 226 227Restores the raw signature data. 228 229**Since**: 12 230 231 232**Parameters** 233 234| Name| Description| 235| -- | -- | 236| [OH_CryptoVerify](capi-cryptosignatureapi-oh-cryptoverify.md) *ctx | Pointer to the **Verify** instance.| 237| [Crypto_DataBlob](capi-cryptocommonapi-crypto-datablob.md) *signData | Pointer to the signature data.| 238| [Crypto_DataBlob](capi-cryptocommonapi-crypto-datablob.md) *rawSignData | Pointer to the raw data restored.| 239 240**Returns** 241 242| Type| Description| 243| -- | -- | 244| [OH_Crypto_ErrCode](capi-crypto-common-h.md#oh_crypto_errcode) | **CRYPTO_SUCCESS**: The operation is successful.<br> **CRYPTO_INVALID_PARAMS**: A parameter is invalid.<br> **CRYPTO_NOT_SUPPORTED**: The operation is not supported.<br> **CRYPTO_MEMORY_ERROR**: A memory error occurs.<br> **CRYPTO_OPERATION_ERROR**: An error occurs when the API of a third-party algorithm library is called.| 245 246### OH_CryptoVerify_GetAlgoName() 247 248``` 249const char *OH_CryptoVerify_GetAlgoName(OH_CryptoVerify *ctx) 250``` 251 252**Description** 253 254Obtains the signature verification algorithm. 255 256**Since**: 12 257 258 259**Parameters** 260 261| Name| Description| 262| -- | -- | 263| [OH_CryptoVerify](capi-cryptosignatureapi-oh-cryptoverify.md) *ctx | Pointer to the **Verify** instance.| 264 265**Returns** 266 267| Type| Description| 268| -- | -- | 269| const char * | Signature verification algorithm obtained.| 270 271### OH_CryptoVerify_SetParam() 272 273``` 274OH_Crypto_ErrCode OH_CryptoVerify_SetParam(OH_CryptoVerify *ctx, CryptoSignature_ParamType type,Crypto_DataBlob *value) 275``` 276 277**Description** 278 279Sets a signature verification parameter. 280 281**Since**: 12 282 283 284**Parameters** 285 286| Name| Description| 287| -- | -- | 288| [OH_CryptoVerify](capi-cryptosignatureapi-oh-cryptoverify.md) *ctx | Pointer to the **Verify** instance.| 289| [CryptoSignature_ParamType](#cryptosignature_paramtype) type | Name of the signature verification parameter to set.| 290| [Crypto_DataBlob](capi-cryptocommonapi-crypto-datablob.md) *value | Pointer to the value of the signature verification parameter to set.| 291 292**Returns** 293 294| Type| Description| 295| -- | -- | 296| [OH_Crypto_ErrCode](capi-crypto-common-h.md#oh_crypto_errcode) | **CRYPTO_SUCCESS**: The operation is successful.<br> **CRYPTO_INVALID_PARAMS**: A parameter is invalid.<br> **CRYPTO_NOT_SUPPORTED**: The operation is not supported.<br> **CRYPTO_MEMORY_ERROR**: A memory error occurs.<br> **CRYPTO_OPERATION_ERROR**: An error occurs when the API of a third-party algorithm library is called.| 297 298### OH_CryptoVerify_GetParam() 299 300``` 301OH_Crypto_ErrCode OH_CryptoVerify_GetParam(OH_CryptoVerify *ctx, CryptoSignature_ParamType type,Crypto_DataBlob *value) 302``` 303 304**Description** 305 306Obtains a signature verification parameter. 307 308**Since**: 12 309 310 311**Parameters** 312 313| Name| Description| 314| -- | -- | 315| [OH_CryptoVerify](capi-cryptosignatureapi-oh-cryptoverify.md) *ctx | Pointer to the **Verify** instance.| 316| [CryptoSignature_ParamType](#cryptosignature_paramtype) type | Name of the signature verification parameter to obtain.| 317| [Crypto_DataBlob](capi-cryptocommonapi-crypto-datablob.md) *value | Pointer to the parameter value obtained.| 318 319**Returns** 320 321| Type| Description| 322| -- | -- | 323| [OH_Crypto_ErrCode](capi-crypto-common-h.md#oh_crypto_errcode) | **CRYPTO_SUCCESS**: The operation is successful.<br> **CRYPTO_INVALID_PARAMS**: A parameter is invalid.<br> **CRYPTO_NOT_SUPPORTED**: The operation is not supported.<br> **CRYPTO_MEMORY_ERROR**: A memory error occurs.<br> **CRYPTO_OPERATION_ERROR**: An error occurs when the API of a third-party algorithm library is called.| 324 325### OH_CryptoVerify_Destroy() 326 327``` 328void OH_CryptoVerify_Destroy(OH_CryptoVerify *ctx) 329``` 330 331**Description** 332 333Destroys a **Verify** instance. 334 335**Since**: 12 336 337 338**Parameters** 339 340| Name| Description| 341| -- | -- | 342| [OH_CryptoVerify](capi-cryptosignatureapi-oh-cryptoverify.md) *ctx | Pointer to the **Verify** instance.| 343 344### OH_CryptoSign_Create() 345 346``` 347OH_Crypto_ErrCode OH_CryptoSign_Create(const char *algoName, OH_CryptoSign **sign) 348``` 349 350**Description** 351 352Creates a signature instance based on the given algorithm name. 353 354**Since**: 20 355 356 357**Parameters** 358 359| Name| Description| 360| -- | -- | 361| const char *algoName | Pointer to the algorithm used to generate the signature instance.<br> For example, **'RSA\|PKCS1\|SHA384'**, **'ECC\|SHA84'**| | | | 362| [OH_CryptoSign](capi-cryptosignatureapi-oh-cryptosign.md) **sign | Pointer to the signature instance.| 363 364**Returns** 365 366| Type| Description| 367| -- | -- | 368| [OH_Crypto_ErrCode](capi-crypto-common-h.md#oh_crypto_errcode) | **CRYPTO_SUCCESS**: The operation is successful.<br> **CRYPTO_NOT_SUPPORTED**: The operation is not supported.<br> **CRYPTO_MEMORY_ERROR**: A memory error occurs.<br> **CRYPTO_PARAMETER_CHECK_FAILED**: The parameter check failed.<br> **CRYPTO_OPERATION_ERROR**: An error occurs when the API of a third-party algorithm library is called.| 369 370### OH_CryptoSign_Init() 371 372``` 373OH_Crypto_ErrCode OH_CryptoSign_Init(OH_CryptoSign *ctx, OH_CryptoPrivKey *privKey) 374``` 375 376**Description** 377 378Initializes a signature instance. 379 380**Since**: 20 381 382 383**Parameters** 384 385| Name| Description| 386| -- | -- | 387| [OH_CryptoSign](capi-cryptosignatureapi-oh-cryptosign.md) *ctx | Pointer to the signature instance.| 388| [OH_CryptoPrivKey](capi-cryptoasymkeyapi-oh-cryptoprivkey.md) *privKey | Pointer to the private key.| 389 390**Returns** 391 392| Type| Description| 393| -- | -- | 394| [OH_Crypto_ErrCode](capi-crypto-common-h.md#oh_crypto_errcode) | **CRYPTO_SUCCESS**: The operation is successful.<br> **CRYPTO_NOT_SUPPORTED**: The operation is not supported.<br> **CRYPTO_MEMORY_ERROR**: A memory error occurs.<br> **CRYPTO_PARAMETER_CHECK_FAILED**: The parameter check failed.<br> **CRYPTO_OPERATION_ERROR**: An error occurs when the API of a third-party algorithm library is called.| 395 396**Reference** 397 398[OH_CryptoSign_Update](#oh_cryptosign_update) 399 400[OH_CryptoSign_Final](#oh_cryptosign_final) 401 402 403### OH_CryptoSign_Update() 404 405``` 406OH_Crypto_ErrCode OH_CryptoSign_Update(OH_CryptoSign *ctx, const Crypto_DataBlob *in) 407``` 408 409**Description** 410 411Updates the data to be signed. 412 413**Since**: 20 414 415 416**Parameters** 417 418| Name| Description| 419| -- | -- | 420| [OH_CryptoSign](capi-cryptosignatureapi-oh-cryptosign.md) *ctx | Pointer to the signature instance.| 421| [const Crypto_DataBlob](capi-cryptocommonapi-crypto-datablob.md) *in | Pointer to the data to be signed.| 422 423**Returns** 424 425| Type| Description| 426| -- | -- | 427| [OH_Crypto_ErrCode](capi-crypto-common-h.md#oh_crypto_errcode) | **CRYPTO_SUCCESS**: The operation is successful.<br> **CRYPTO_NOT_SUPPORTED**: The operation is not supported.<br> **CRYPTO_MEMORY_ERROR**: A memory error occurs.<br> **CRYPTO_PARAMETER_CHECK_FAILED**: The parameter check failed.<br> **CRYPTO_OPERATION_ERROR**: An error occurs when the API of a third-party algorithm library is called.| 428 429**Reference** 430 431[OH_CryptoSign_Init](#oh_cryptosign_init) 432 433[OH_CryptoSign_Final](#oh_cryptosign_final) 434 435 436### OH_CryptoSign_Final() 437 438``` 439OH_Crypto_ErrCode OH_CryptoSign_Final(OH_CryptoSign *ctx, const Crypto_DataBlob *in, Crypto_DataBlob *out) 440``` 441 442**Description** 443 444Finalizes the signing operation. 445 446**Since**: 20 447 448 449**Parameters** 450 451| Name| Description| 452| -- | -- | 453| [OH_CryptoSign](capi-cryptosignatureapi-oh-cryptosign.md) *ctx | Pointer to the signature instance.| 454| [const Crypto_DataBlob](capi-cryptocommonapi-crypto-datablob.md) *in | Pointer to the data to be signed.| 455| [Crypto_DataBlob](capi-cryptocommonapi-crypto-datablob.md) *out | Pointer to the signing result.| 456 457**Returns** 458 459| Type| Description| 460| -- | -- | 461| [OH_Crypto_ErrCode](capi-crypto-common-h.md#oh_crypto_errcode) | **CRYPTO_SUCCESS**: The operation is successful.<br> **CRYPTO_NOT_SUPPORTED**: The operation is not supported.<br> **CRYPTO_MEMORY_ERROR**: A memory error occurs.<br> **CRYPTO_PARAMETER_CHECK_FAILED**: The parameter check failed.<br> **CRYPTO_OPERATION_ERROR**: An error occurs when the API of a third-party algorithm library is called.| 462 463**Reference** 464 465[OH_CryptoSign_Init](#oh_cryptosign_init) 466 467[OH_CryptoSign_Update](#oh_cryptosign_update) 468 469 470### OH_CryptoSign_GetAlgoName() 471 472``` 473const char *OH_CryptoSign_GetAlgoName(OH_CryptoSign *ctx) 474``` 475 476**Description** 477 478Obtains the algorithm name of a signature instance. 479 480**Since**: 20 481 482 483**Parameters** 484 485| Name| Description| 486| -- | -- | 487| [OH_CryptoSign](capi-cryptosignatureapi-oh-cryptosign.md) *ctx | Pointer to the signature instance.| 488 489**Returns** 490 491| Type| Description| 492| -- | -- | 493| const char * | Algorithm name of the signature instance.| 494 495### OH_CryptoSign_SetParam() 496 497``` 498OH_Crypto_ErrCode OH_CryptoSign_SetParam(OH_CryptoSign *ctx, CryptoSignature_ParamType type,const Crypto_DataBlob *value) 499``` 500 501**Description** 502 503Sets parameters for a signature instance. 504 505**Since**: 20 506 507 508**Parameters** 509 510| Name| Description| 511| -- | -- | 512| [OH_CryptoSign](capi-cryptosignatureapi-oh-cryptosign.md) *ctx | Pointer to the signature instance.| 513| [CryptoSignature_ParamType](#cryptosignature_paramtype) type | Pointer to the signature parameter type.| 514| [const Crypto_DataBlob](capi-cryptocommonapi-crypto-datablob.md) *value | Pointer to the input data.| 515 516**Returns** 517 518| Type| Description| 519| -- | -- | 520| [OH_Crypto_ErrCode](capi-crypto-common-h.md#oh_crypto_errcode) | **CRYPTO_SUCCESS**: The operation is successful.<br> **CRYPTO_NOT_SUPPORTED**: The operation is not supported.<br> **CRYPTO_MEMORY_ERROR**: A memory error occurs.<br> **CRYPTO_PARAMETER_CHECK_FAILED**: The parameter check failed.<br> **CRYPTO_OPERATION_ERROR**: An error occurs when the API of a third-party algorithm library is called.| 521 522### OH_CryptoSign_GetParam() 523 524``` 525OH_Crypto_ErrCode OH_CryptoSign_GetParam(OH_CryptoSign *ctx, CryptoSignature_ParamType type, Crypto_DataBlob *value) 526``` 527 528**Description** 529 530Obtains the specified parameter from a signature instance. 531 532**Since**: 20 533 534 535**Parameters** 536 537| Name| Description| 538| -- | -- | 539| [OH_CryptoSign](capi-cryptosignatureapi-oh-cryptosign.md) *ctx | Pointer to the signature instance.| 540| [CryptoSignature_ParamType](#cryptosignature_paramtype) type | Pointer to the signature parameter type.| 541| [Crypto_DataBlob](capi-cryptocommonapi-crypto-datablob.md) *value | Pointer to the output data.| 542 543**Returns** 544 545| Type| Description| 546| -- | -- | 547| [OH_Crypto_ErrCode](capi-crypto-common-h.md#oh_crypto_errcode) | **CRYPTO_SUCCESS**: The operation is successful.<br> **CRYPTO_NOT_SUPPORTED**: The operation is not supported.<br> **CRYPTO_MEMORY_ERROR**: A memory error occurs.<br> **CRYPTO_PARAMETER_CHECK_FAILED**: The parameter check failed.<br> **CRYPTO_OPERATION_ERROR**: An error occurs when the API of a third-party algorithm library is called.| 548 549### OH_CryptoSign_Destroy() 550 551``` 552void OH_CryptoSign_Destroy(OH_CryptoSign *ctx) 553``` 554 555**Description** 556 557Destroys a signature instance. 558 559**Since**: 20 560 561 562**Parameters** 563 564| Name| Description| 565| -- | -- | 566| [OH_CryptoSign](capi-cryptosignatureapi-oh-cryptosign.md) *ctx | Pointer to the signature instance.| 567 568### OH_CryptoEccSignatureSpec_Create() 569 570``` 571OH_Crypto_ErrCode OH_CryptoEccSignatureSpec_Create(Crypto_DataBlob *eccSignature,OH_CryptoEccSignatureSpec **spec) 572``` 573 574**Description** 575 576Creates ECC signing specifications. 577 578**Since**: 20 579 580 581**Parameters** 582 583| Name| Description| 584| -- | -- | 585| [Crypto_DataBlob](capi-cryptocommonapi-crypto-datablob.md) *eccSignature | Pointer to the ECC signature (in DER format). If **EccSignature** is **NULL**, an empty ECC signing specification is created.| 586| [OH_CryptoEccSignatureSpec](capi-cryptosignatureapi-oh-cryptoeccsignaturespec.md) **spec | Pointer to the ECC signing specifications.| 587 588**Returns** 589 590| Type| Description| 591| -- | -- | 592| [OH_Crypto_ErrCode](capi-crypto-common-h.md#oh_crypto_errcode) | **CRYPTO_SUCCESS**: The operation is successful.<br> **CRYPTO_NOT_SUPPORTED**: The operation is not supported.<br> **CRYPTO_MEMORY_ERROR**: A memory error occurs.<br> **CRYPTO_PARAMETER_CHECK_FAILED**: The parameter check failed.<br> **CRYPTO_OPERATION_ERROR**: An error occurs when the API of a third-party algorithm library is called.| 593 594### OH_CryptoEccSignatureSpec_GetRAndS() 595 596``` 597OH_Crypto_ErrCode OH_CryptoEccSignatureSpec_GetRAndS(OH_CryptoEccSignatureSpec *spec, Crypto_DataBlob *r,Crypto_DataBlob *s) 598``` 599 600**Description** 601 602Obtains the **r** and **s** values of an ECC signature. 603 604**Since**: 20 605 606 607**Parameters** 608 609| Name| Description| 610| -- | -- | 611| [OH_CryptoEccSignatureSpec](capi-cryptosignatureapi-oh-cryptoeccsignaturespec.md) *spec | Pointer to the ECC signing specifications.| 612| [Crypto_DataBlob](capi-cryptocommonapi-crypto-datablob.md) *r | Pointer to the **r** value.| 613| [Crypto_DataBlob](capi-cryptocommonapi-crypto-datablob.md) *s | Pointer to the **s** value.| 614 615**Returns** 616 617| Type| Description| 618| -- | -- | 619| [OH_Crypto_ErrCode](capi-crypto-common-h.md#oh_crypto_errcode) | **CRYPTO_SUCCESS**: The operation is successful.<br> **CRYPTO_NOT_SUPPORTED**: The operation is not supported.<br> **CRYPTO_MEMORY_ERROR**: A memory error occurs.<br> **CRYPTO_PARAMETER_CHECK_FAILED**: The parameter check failed.<br> **CRYPTO_OPERATION_ERROR**: An error occurs when the API of a third-party algorithm library is called.| 620 621### OH_CryptoEccSignatureSpec_SetRAndS() 622 623``` 624OH_Crypto_ErrCode OH_CryptoEccSignatureSpec_SetRAndS(OH_CryptoEccSignatureSpec *spec, Crypto_DataBlob *r,Crypto_DataBlob *s) 625``` 626 627**Description** 628 629Sets the **r** and **s** values of an ECC signature. 630 631**Since**: 20 632 633 634**Parameters** 635 636| Name| Description| 637| -- | -- | 638| [OH_CryptoEccSignatureSpec](capi-cryptosignatureapi-oh-cryptoeccsignaturespec.md) *spec | Pointer to the ECC signing specifications.| 639| [Crypto_DataBlob](capi-cryptocommonapi-crypto-datablob.md) *r | Pointer to the **r** value.| 640| [Crypto_DataBlob](capi-cryptocommonapi-crypto-datablob.md) *s | Pointer to the **s** value.| 641 642**Returns** 643 644| Type| Description| 645| -- | -- | 646| [OH_Crypto_ErrCode](capi-crypto-common-h.md#oh_crypto_errcode) | **CRYPTO_SUCCESS**: The operation is successful.<br> **CRYPTO_NOT_SUPPORTED**: The operation is not supported.<br> **CRYPTO_MEMORY_ERROR**: A memory error occurs.<br> **CRYPTO_PARAMETER_CHECK_FAILED**: The parameter check failed.<br> **CRYPTO_OPERATION_ERROR**: An error occurs when the API of a third-party algorithm library is called.| 647 648### OH_CryptoEccSignatureSpec_Encode() 649 650``` 651OH_Crypto_ErrCode OH_CryptoEccSignatureSpec_Encode(OH_CryptoEccSignatureSpec *spec, Crypto_DataBlob *out) 652``` 653 654**Description** 655 656Encodes ECC signing specifications into a signature in DER format. 657 658**Since**: 20 659 660 661**Parameters** 662 663| Name| Description| 664| -- | -- | 665| [OH_CryptoEccSignatureSpec](capi-cryptosignatureapi-oh-cryptoeccsignaturespec.md) *spec | Pointer to the ECC signing specifications.| 666| [Crypto_DataBlob](capi-cryptocommonapi-crypto-datablob.md) *out | Pointer to the output data.| 667 668**Returns** 669 670| Type| Description| 671| -- | -- | 672| [OH_Crypto_ErrCode](capi-crypto-common-h.md#oh_crypto_errcode) | **CRYPTO_SUCCESS**: The operation is successful.<br> **CRYPTO_NOT_SUPPORTED**: The operation is not supported.<br> **CRYPTO_MEMORY_ERROR**: A memory error occurs.<br> **CRYPTO_PARAMETER_CHECK_FAILED**: The parameter check failed.<br> **CRYPTO_OPERATION_ERROR**: An error occurs when the API of a third-party algorithm library is called.| 673 674### OH_CryptoEccSignatureSpec_Destroy() 675 676``` 677void OH_CryptoEccSignatureSpec_Destroy(OH_CryptoEccSignatureSpec *spec) 678``` 679 680**Description** 681 682Destroys ECC signing specifications. 683 684**Since**: 20 685 686 687**Parameters** 688 689| Name| Description| 690| -- | -- | 691| [OH_CryptoEccSignatureSpec](capi-cryptosignatureapi-oh-cryptoeccsignaturespec.md) *spec | Pointer to the ECC signing specifications.| 692