Add comparison operations for keys
daurnimator opened this issue · comments
daurnimator commented
Currenly to see if two key objects contain the same key I have to convert them to PEM and compare the strings.
Instead, it would be nice to have an __eq
that uses EVP_PKEY_cmp_parameters
.
daurnimator commented
EVP_PKEY_cmp_parameters
doesn't work for all key types (notably RSA)
EVP_PKEY_cmp
only checks the public keys match, not the private.
This doesn't seem to be possible without delving into each key type, so closing.
Useful test script:
#!/usr/bin/env lua
local pkey = require"openssl.pkey"
local a = pkey.new()
local b = pkey.new(a:toPEM("private"))
assert(a==b)
local c = pkey.new(a:toPEM("public"))
assert(a~=c)