Class: ECHConfig::ECHConfigContents::HpkeKeyConfig::HpkeSymmetricCipherSuite

Inherits:
Object
  • Object
show all
Defined in:
lib/ech_config/ech_config_contents/hpke_key_config/hpke_symmetric_cipher_suite.rb,
lib/ech_config/ech_config_contents/hpke_key_config/hpke_symmetric_cipher_suite.rb,
sig/generated/ech_config/ech_config_contents/hpke_key_config/hpke_symmetric_cipher_suite.rbs,
sig/generated/ech_config/ech_config_contents/hpke_key_config/hpke_symmetric_cipher_suite.rbs

Overview

rbs_inline: enabled

Defined Under Namespace

Classes: HpkeAeadId, HpkeKdfId

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kdf_id, aead_id) ⇒ HpkeSymmetricCipherSuite

Returns a new instance of HpkeSymmetricCipherSuite.



18
19
20
21
# File 'lib/ech_config/ech_config_contents/hpke_key_config/hpke_symmetric_cipher_suite.rb', line 18

def initialize(kdf_id, aead_id)
  @kdf_id = kdf_id
  @aead_id = aead_id
end

Instance Attribute Details

#aead_id ⇒ Object (readonly)

Returns the value of attribute aead_id.

Returns:

  • (Object)


13
14
15
# File 'lib/ech_config/ech_config_contents/hpke_key_config/hpke_symmetric_cipher_suite.rb', line 13

def aead_id
  @aead_id
end

#kdf_id ⇒ Object (readonly)

Returns the value of attribute kdf_id.

Returns:

  • (Object)


13
14
15
# File 'lib/ech_config/ech_config_contents/hpke_key_config/hpke_symmetric_cipher_suite.rb', line 13

def kdf_id
  @kdf_id
end

Class Method Details

.decode_vectors(octet) ⇒ Array[ECHConfig::ECHConfigContents::HpkeKeyConfig::HpkeSymmetricCipherSuite]

Parameters:

  • octet (String)

Returns:



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/ech_config/ech_config_contents/hpke_key_config/hpke_symmetric_cipher_suite.rb', line 36

def self.decode_vectors(octet)
  i = 0
  cipher_suites = [] # @type var cipher_suites: Array[ECHConfig::ECHConfigContents::HpkeKeyConfig::HpkeSymmetricCipherSuite]
  while i < octet.length
    raise ::ECHConfig::DecodeError if i + 4 > octet.length

    kdf_id = HpkeKdfId.decode(octet.slice(i, 2) || '')
    aead_id = HpkeAeadId.decode(octet.slice(i + 2, 2) || '')
    i += 4
    cipher_suites << new(kdf_id, aead_id)
  end

  cipher_suites
end

Instance Method Details

#==(other) ⇒ Boolean



30
31
32
# File 'lib/ech_config/ech_config_contents/hpke_key_config/hpke_symmetric_cipher_suite.rb', line 30

def ==(other)
  other.kdf_id == @kdf_id && other.aead_id == @aead_id
end

#encode ⇒ String

Returns:

  • (String)


24
25
26
# File 'lib/ech_config/ech_config_contents/hpke_key_config/hpke_symmetric_cipher_suite.rb', line 24

def encode
  @kdf_id.encode + @aead_id.encode
end