123456789_123456789_123456789_123456789_123456789_

Class: OpenSSL::HPKE::Context

Relationships & Source Files
Namespace Children
Classes:
Extension / Inclusion / Inheritance Descendants
Subclasses:
Inherits: Object
Defined in: ext/openssl/ossl_hpke.c,
ext/openssl/ossl_hpke.c

Overview

Abstract class for ::OpenSSL::HPKE contexts to be used in subsequent ::OpenSSL::HPKE operations. Depending on the actor in the protocol, either Sender or Receiver will be used.

Instance Method Summary

Instance Method Details

#export(secretlen, label) ⇒ secret

Derives and returns a secretlen-byte exporter secret bound to label, as a String. Both parties obtain the same secret only after the shared context has been established: the sender via Sender#encap and the receiver via Receiver#decap. Different label values yield independent secrets.

[ GitHub ]

  
# File 'ext/openssl/ossl_hpke.c', line 333

static VALUE
ossl_hpke_export(VALUE self, VALUE secretlen, VALUE label)
{
    VALUE secret_obj;
    ossl_hpke_ctx_t *data;
    size_t labellen;
    int outlen = NUM2INT(secretlen);

    StringValue(label);
    labellen = RSTRING_LEN(label);

    secret_obj = rb_str_new(0, outlen);

    GetHpke(self, data);
    if (OSSL_HPKE_export(data->ctx, (unsigned char *)RSTRING_PTR(secret_obj),
                         outlen, (unsigned char *)RSTRING_PTR(label),
                         labellen) != 1) {
        ossl_raise(eHPKEError, "could not export");
    }

    return secret_obj;
}