Contents

SecKeyDecrypt(_:_:_:_:_:_:)

Decrypts a block of ciphertext.

Declaration

func SecKeyDecrypt(_ key: SecKey, _ padding: SecPadding, _ cipherText: UnsafePointer<UInt8>, _ cipherTextLen: Int, _ plainText: UnsafeMutablePointer<UInt8>, _ plainTextLen: UnsafeMutablePointer<Int>) -> OSStatus

Parameters

  • key:

    Private key with which to decrypt the data.

  • padding:

    The type of padding used. Possible values are listed in Secpadding. Typically, Pkcs1 is used, which removes PKCS1 padding after decryption. If you specify Ksecpaddingnone, the decrypted data is returned as-is.

  • cipherText:

    The data to decrypt.

  • cipherTextLen:

    Length in bytes of the data in the cipherText buffer. This must be less than or equal to the value returned by the Seckeygetblocksize(_:) function.

  • plainText:

    On return, the decrypted text.

  • plainTextLen:

    On entry, the size of the buffer provided in the plainText parameter. On return, the amount of data actually placed in the buffer.

Return Value

A result code. See Security Framework Result Codes.

Discussion

The input buffer (cipherText) can be the same as the output buffer (plainText) to reduce the amount of memory used by the function.