81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
else
return lib.pk.mbedtls_pk_write_key_pem(key, buf, const.maxpemsz) == 0
end
end
local binblob = lib.mem.ptr(uint8)
terra m.der(pub: bool, key: &ctx, buf: &uint8): binblob
var ofs: intptr
if pub then
ofs = lib.pk.mbedtls_pk_write_pubkey_der(key, buf, const.maxdersz)
else
ofs = lib.pk.mbedtls_pk_write_key_der(key, buf, const.maxdersz)
end
return binblob {
ptr = buf + (const.maxdersz - ofs);
ct = ofs;
}
end
m.destroy = lib.dispatch {
|
|
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
else
return lib.pk.mbedtls_pk_write_key_pem(key, buf, const.maxpemsz) == 0
end
end
local binblob = lib.mem.ptr(uint8)
terra m.der(pub: bool, key: &ctx, buf: &uint8): binblob
var ofs: ptrdiff
if pub then
ofs = lib.pk.mbedtls_pk_write_pubkey_der(key, buf, const.maxdersz)
else
ofs = lib.pk.mbedtls_pk_write_key_der(key, buf, const.maxdersz)
end
if ofs < 0 then return binblob.null() end
return binblob {
ptr = buf + (const.maxdersz - ofs);
ct = ofs;
}
end
m.destroy = lib.dispatch {
|