NAME

Apertur::SDK::Crypto - Image encryption for Apertur uploads

SYNOPSIS

use Apertur::SDK::Crypto qw(encrypt_image);

my $result = encrypt_image($image_bytes, $public_key_pem);
# $result->{encrypted_key}   - Base64-encoded RSA-wrapped AES key
# $result->{iv}              - Base64-encoded 12-byte IV
# $result->{encrypted_data}  - Base64-encoded AES-256-GCM ciphertext + tag
# $result->{algorithm}       - "RSA-OAEP+AES-256-GCM"

DESCRIPTION

Encrypts image data using AES-256-GCM with a random key, then wraps the AES key using RSA-OAEP with SHA-256. Requires optional dependencies Crypt::OpenSSL::RSA and CryptX; these are loaded at runtime only when encryption is actually used.

FUNCTIONS

encrypt_image($image_data, $public_key_pem)

Encrypts the given image bytes with the provided PEM-encoded RSA public key. Returns a hashref with encrypted_key, iv, encrypted_data, and algorithm (all strings, base64-encoded where applicable).