class OpenSSL::HPKE::Suite
Value object that specifies the HPKE cipher suite.
Public Class Methods
Source
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);
}
Public Instance Methods
Source
static VALUE
ossl_hpke_suite_aead_id(VALUE self)
{
OSSL_HPKE_SUITE *suite;
GetHpkeSuite(self, suite);
return INT2NUM(suite->aead_id);
}
Returns the IANA AEAD algorithm ID of the suite as an Integer.
Source
static VALUE
ossl_hpke_suite_kdf_id(VALUE self)
{
OSSL_HPKE_SUITE *suite;
GetHpkeSuite(self, suite);
return INT2NUM(suite->kdf_id);
}
Source
static VALUE
ossl_hpke_suite_kem_id(VALUE self)
{
OSSL_HPKE_SUITE *suite;
GetHpkeSuite(self, suite);
return INT2NUM(suite->kem_id);
}
Returns the IANA KEM (Key Encapsulation Mechanism) algorithm ID of the suite as an Integer.