Sane C++ Libraries
C++ Platform Abstraction Libraries
Loading...
Searching...
No Matches
SC::Cryptography::Cipher Struct Reference

Public Types

enum class  Operation : uint8_t {
  Encrypt ,
  Decrypt
}
 
using InternalOpaque = OpaqueObject<InternalDefinition>
 

Public Member Functions

 Cipher ()
 Construct a session using the default native backend.
 
 Cipher (Backend backend)
 Construct a session using an explicitly selected backend.
 
 Cipher (const Cipher &)=delete
 
 Cipher (Cipher &&)=delete
 
Cipheroperator= (const Cipher &)=delete
 
Cipheroperator= (Cipher &&)=delete
 
Result start (CipherType type, Operation operation, Span< const uint8_t > key, Span< const uint8_t > iv)
 Start a legacy AES-CBC PKCS#7 operation.
 
Result update (Span< const uint8_t > input, Span< uint8_t > output, size_t &bytesWritten)
 Process the next chunk of bytes.
 
Result finish (Span< uint8_t > output, size_t &bytesWritten)
 Finalize the operation and flush the remaining bytes / padding.
 
void reset ()
 Discard the current operation and clear library-owned session state.
 

Constructor & Destructor Documentation

◆ Cipher() [1/2]

SC::Cryptography::Cipher::Cipher ( )

Construct a session using the default native backend.

◆ Cipher() [2/2]

SC::Cryptography::Cipher::Cipher ( Backend backend)
explicit

Construct a session using an explicitly selected backend.

Member Function Documentation

◆ finish()

Result SC::Cryptography::Cipher::finish ( Span< uint8_t > output,
size_t & bytesWritten )

Finalize the operation and flush the remaining bytes / padding.

Note
Output must have at least 16 bytes. Success and invalid ciphertext or padding consume the session. bytesWritten is always zero on failure.

◆ reset()

void SC::Cryptography::Cipher::reset ( )

Discard the current operation and clear library-owned session state.

Note
This operation is idempotent.

◆ start()

Result SC::Cryptography::Cipher::start ( CipherType type,
Operation operation,
Span< const uint8_t > key,
Span< const uint8_t > iv )

Start a legacy AES-CBC PKCS#7 operation.

Warning
AES-CBC does not authenticate ciphertext. Use only when required by an existing authenticated protocol. Encryption IVs must be unpredictable and freshly generated for each message.
Note
Every start attempt discards the previous operation, including when start fails.

◆ update()

Result SC::Cryptography::Cipher::update ( Span< const uint8_t > input,
Span< uint8_t > output,
size_t & bytesWritten )

Process the next chunk of bytes.

Note
Input and output must not overlap. An output span of input size plus 15 bytes is always sufficient. An insufficient output span fails without consuming input and can be retried. bytesWritten is always zero on failure.

The documentation for this struct was generated from the following file: