12 #define NewSPKI(klass) \ 13 TypedData_Wrap_Struct((klass), &ossl_netscape_spki_type, 0) 14 #define SetSPKI(obj, spki) do { \ 16 ossl_raise(rb_eRuntimeError, "SPKI wasn't initialized!"); \ 18 RTYPEDDATA_DATA(obj) = (spki); \ 20 #define GetSPKI(obj, spki) do { \ 21 TypedData_Get_Struct((obj), NETSCAPE_SPKI, &ossl_netscape_spki_type, (spki)); \ 23 ossl_raise(rb_eRuntimeError, "SPKI wasn't initialized!"); \ 43 ossl_netscape_spki_free(
void *spki)
45 NETSCAPE_SPKI_free(spki);
49 "OpenSSL/NETSCAPE_SPKI",
51 0, ossl_netscape_spki_free,
57 ossl_spki_alloc(
VALUE klass)
63 if (!(spki = NETSCAPE_SPKI_new())) {
83 const unsigned char *p;
109 ossl_spki_to_der(
VALUE self)
117 if ((len = i2d_NETSCAPE_SPKI(spki,
NULL)) <= 0)
121 if (i2d_NETSCAPE_SPKI(spki, &p) <= 0)
135 ossl_spki_to_pem(
VALUE self)
142 if (!(data = NETSCAPE_SPKI_b64_encode(spki))) {
158 ossl_spki_print(
VALUE self)
164 if (!(out = BIO_new(BIO_s_mem()))) {
167 if (!NETSCAPE_SPKI_print(out, spki)) {
183 ossl_spki_get_public_key(
VALUE self)
189 if (!(pkey = NETSCAPE_SPKI_get_pubkey(spki))) {
213 if (!NETSCAPE_SPKI_set_pubkey(spki,
GetPKeyPtr(key))) {
227 ossl_spki_get_challenge(
VALUE self)
232 if (spki->spkac->challenge->length <= 0) {
237 return rb_str_new((
const char *)spki->spkac->challenge->data,
238 spki->spkac->challenge->length);
252 ossl_spki_set_challenge(
VALUE self,
VALUE str)
258 if (!ASN1_STRING_set(spki->spkac->challenge,
RSTRING_PTR(str),
289 if (!NETSCAPE_SPKI_sign(spki, pkey, md)) {
312 switch (NETSCAPE_SPKI_verify(spki,
GetPKeyPtr(key))) {
#define RUBY_TYPED_FREE_IMMEDIATELY
size_t strlen(const char *)
EVP_PKEY * GetPrivPKeyPtr(VALUE obj)
#define ossl_str_adjust(str, p)
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
VALUE ossl_membio2str(BIO *bio)
VALUE ossl_pkey_new(EVP_PKEY *pkey)
void ossl_clear_error(void)
RUBY_EXTERN VALUE rb_cObject
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
const EVP_MD * ossl_evp_get_digestbyname(VALUE obj)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
register unsigned int len
void Init_ossl_ns_spki(void)
VALUE rb_define_module_under(VALUE outer, const char *name)
#define SetSPKI(obj, spki)
VALUE ossl_buf2str(char *buf, int len)
void ossl_raise(VALUE exc, const char *fmt,...)
EVP_PKEY * GetPKeyPtr(VALUE obj)
#define RSTRING_LENINT(str)
VALUE rb_define_module(const char *name)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
#define GetSPKI(obj, spki)
VALUE rb_str_new(const char *, long)