SCM iOS API
PrivateKey Class Reference

Class describes a private key object. Inherits from Key. More...

Inheritance diagram for PrivateKey:
Key TokenObject

Instance Methods

(Boolean) - isPartialHash
 
(void) - hashAndSign:hashAlg:completionHandler:
 
(void) - sign:hashAlg:completionHandler:
 
(void) - decrypt:completionHandler:
 
- Instance Methods inherited from Key
(NSString *) - getKeyType
 
(NSString *) - getAlgorithmName
 
(NSUInteger) - getkeyLength
 
(void) - getModulus:
 
(void) - getPublicExponent:
 
- Instance Methods inherited from TokenObject
(NSString *) - getType
 
(NSString *) - getCkLabel
 
(NSString *) - getCkId
 
(Token *) - getParent
 
(NSUInteger) - getPinNumber
 

Detailed Description

Class describes a private key object. Inherits from Key.

Note that the constructor is not intended to be called by user code. Such objects are constructed internally by the API.

Method Documentation

◆ decrypt:completionHandler:()

- (void) decrypt: (NSData *)  data
completionHandler: (void(^)(NSData *dataDecrypted, NSError *))  completionHandler 

Decrypts the provided data using a private key. The operation will use PKCS#1 padding.

Parameters
dataNSData containing the ciphertext data to decrypt.
completionHandlerthe completion handler to call when the decryption is complete. The completion handler is executed on the main queue and takes the following parameters :
  • dataDecrypted an NSData containing the plaintext.
  • error nil if the decryption is completed successfully; otherwise an NSError encapsulates the reason of failure.

◆ hashAndSign:hashAlg:completionHandler:()

- (void) hashAndSign: (NSData*)  data
hashAlg: (NSString *)  hashAlg
completionHandler: (void(^)(NSData *signature, NSError *error))  completionHandler 

Hashes the provided data and signs the hash using a private key. The operation will use PKCS#1 padding.

The hashAlg parameter indicates the hash algorithm to use and can take the following values :

  • "sha1" or "sha256" : Available for all keys (SHA-1 may be forbidden with qualified signature keys depending on the card profil;
  • "sha384" or "sha512" : Not available for qualified keys.
Parameters
datadata to hash, provided as NSData.
hashAlgalgorithm of the hash.
completionHandlerthe completion handler to call when the signature is complete. The completion handler is executed on the main queue and takes the following parameters :
  • signature an NSData containing the signature.
  • error nil if the signature is completed successfully; otherwise an NSError encapsulates the reason of failure.

◆ isPartialHash()

- (Boolean) isPartialHash

Returns YES if the key must use partial hashing (qualified signature key). Available only for private keys.

Returns
YES if the key must use partial hashing; NO otherwise.

◆ sign:hashAlg:completionHandler:()

- (void) sign: (NSData *)  hash
hashAlg: (NSString *)  hashAlg
completionHandler: (void(^)(NSData *signature, NSError *))  completionHandler 

Signs the provided hash using a private key. The operation will use PKCS#1 padding.

The algorithm of the hash needs to be indicates if the OID needs to be added within the signature block. The hashAlg parameter can take the following values :

  • "nil": The hash data will be signed as provided. Not available for qualified signature keys.
  • "sha1" , "sha256" , "sha384" or "sha512" : The corresponding OIS will be prepended. Not available for qualified signature.
  • "sha1-partial" or "sha256-partial" : The hash must be provided as a partial hash block (containing intermediate hash values).

The PrivateKey#isPartialHash method can be used to check whether the key is a qualified signature key that requires partial hashing.

Parameters
hashthe hash value.
hashAlgalgorithm of the hash.
completionHandlerthe completion handler to call when the signature is complete. The completion handler is executed on the main queue and takes the following parameters :
  • signature an NSData containing the signature.
  • error nil if the signature is completed successfully; otherwise an NSError encapsulates the reason of failure.

The documentation for this class was generated from the following files: