Sha256: d50fecc8573bb7f6c674757c7d01056ef36772f5f5eb0b4ee6d32894af870979

Contents?: true

Size: 688 Bytes

Versions: 10

Compression:

Stored size: 688 Bytes

Contents

require 'aead/cipher'
require 'aead/cipher/aes_hmac'

require 'securerandom'

#
# Encrypt plaintext using the CBC mode of AES and authenticate the
# result with HMAC-SHA-256.
#
class AEAD::Cipher::AES_256_CBC_HMAC_SHA_256 < AEAD::Cipher
  include AEAD::Cipher::AES_HMAC

  def self.key_len;   64; end
  def self.iv_len;    16; end
  def self.nonce_len; 16; end
  def self.tag_len;   32; end

  def self.encryption_key_len; 32; end
  def self.signing_key_len;    32; end

  def self.cipher_mode; 'aes-256-cbc'; end
  def self.digest_mode; 'SHA256'; end

  #
  # CBC requires a randomly-generated nonce.
  #
  def self.generate_nonce
    SecureRandom.random_bytes(self.nonce_len)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
aead-1.8.1 lib/aead/cipher/aes_256_cbc_hmac_sha_256.rb
aead-1.8.0 lib/aead/cipher/aes_256_cbc_hmac_sha_256.rb
aead-1.7.1 lib/aead/cipher/aes_256_cbc_hmac_sha_256.rb
aead-1.7.0 lib/aead/cipher/aes_256_cbc_hmac_sha_256.rb
aead-1.6.2 lib/aead/cipher/aes_256_cbc_hmac_sha_256.rb
aead-1.6.1 lib/aead/cipher/aes_256_cbc_hmac_sha_256.rb
aead-1.5.1 lib/aead/cipher/aes_256_cbc_hmac_sha_256.rb
aead-1.5.0 lib/aead/cipher/aes_256_cbc_hmac_sha_256.rb
aead-1.3.1 lib/aead/cipher/aes_256_cbc_hmac_sha_256.rb
aead-1.3.0 lib/aead/cipher/aes_256_cbc_hmac_sha_256.rb