Class: OpenSSL::HPKE::Suite
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | ext/openssl/ossl_hpke.c, ext/openssl/ossl_hpke.c |
Overview
Value object that specifies the ::OpenSSL::HPKE cipher suite.
Class Method Summary
-
.new(kem, kdf, aead) ⇒ Suite
constructor
kem,kdf, andaeadare either all algorithm name strings (resolved via OSSL_HPKE_str2suite) or all::IntegerIANA algorithm IDs (as carried on the wire by e.g. ECH).
Instance Method Summary
-
#aead_id ⇒ Integer
Returns the IANA AEAD algorithm ID of the suite as an
::Integer. -
#kdf_id ⇒ Integer
Returns the IANA KDF (Key Derivation Function) algorithm ID of the suite as an
::Integer. -
#kem_id ⇒ Integer
Returns the IANA KEM (Key Encapsulation Mechanism) algorithm ID of the suite as an
::Integer.
Constructor Details
.new(kem, kdf, aead) ⇒ Suite
# File 'ext/openssl/ossl_hpke.c', line 377
static VALUE
ossl_hpke_suite_initialize(VALUE self, VALUE kem, VALUE kdf, VALUE aead)
{
OSSL_HPKE_SUITE *suite, tmp;
if (RTYPEDDATA_DATA(self))
ossl_raise(eHPKEError, "HPKE suite is already initialized");
if (RB_INTEGER_TYPE_P(kem) && RB_INTEGER_TYPE_P(kdf) &&
RB_INTEGER_TYPE_P(aead)) {
tmp.kem_id = ossl_hpke_suite_id(kem, "KEM");
tmp.kdf_id = ossl_hpke_suite_id(kdf, "KDF");
tmp.aead_id = ossl_hpke_suite_id(aead, "AEAD");
if (OSSL_HPKE_suite_check(tmp) != 1) {
ossl_raise(eHPKEError, "unsupported HPKE suite: "
"kem=0x%04x kdf=0x%04x aead=0x%04x",
tmp.kem_id, tmp.kdf_id, tmp.aead_id);
}
}
else {
VALUE str = rb_sprintf("%"PRIsVALUE",%"PRIsVALUE",%"PRIsVALUE,
kem, kdf, aead);
if (OSSL_HPKE_str2suite(StringValueCStr(str), &tmp) != 1)
ossl_raise(eHPKEError, "unsupported HPKE suite: %"PRIsVALUE, str);
}
suite = ALLOC(OSSL_HPKE_SUITE);
*suite = tmp;
RTYPEDDATA_DATA(self) = suite;
/*
* A Suite is immutable: its algorithm IDs never change, and they are
* copied into the Context at construction rather than read back later.
* Freeze it so the immutability is enforced and visible to callers.
*/
return rb_obj_freeze(self);
}
Instance Method Details
#aead_id ⇒ Integer
Returns the IANA AEAD algorithm ID of the suite as an ::Integer.
# File 'ext/openssl/ossl_hpke.c', line 453
static VALUE
ossl_hpke_suite_aead_id(VALUE self)
{
OSSL_HPKE_SUITE *suite;
GetHpkeSuite(self, suite);
return INT2NUM(suite->aead_id);
}
#kdf_id ⇒ Integer
Returns the IANA KDF (Key Derivation Function) algorithm ID of the suite
as an ::Integer.
# File 'ext/openssl/ossl_hpke.c', line 439
static VALUE
ossl_hpke_suite_kdf_id(VALUE self)
{
OSSL_HPKE_SUITE *suite;
GetHpkeSuite(self, suite);
return INT2NUM(suite->kdf_id);
}
#kem_id ⇒ Integer
Returns the IANA KEM (Key Encapsulation Mechanism) algorithm ID of the
suite as an ::Integer.
# File 'ext/openssl/ossl_hpke.c', line 424
static VALUE
ossl_hpke_suite_kem_id(VALUE self)
{
OSSL_HPKE_SUITE *suite;
GetHpkeSuite(self, suite);
return INT2NUM(suite->kem_id);
}