pub struct SecretKey { /* private fields */ }rsa only.Expand description
SecretKey contains a 2048-bit RSA private key usable for signing, with SHA256 as the underlying hash algorithm. Whilst RSA could also be used for encryption, that is not exposed on the API as it’s not required by the project.
Implementations§
Source§impl SecretKey
impl SecretKey
Sourcepub fn from_bytes(bytes: &[u8; 520]) -> Result<Self, Error>
pub fn from_bytes(bytes: &[u8; 520]) -> Result<Self, Error>
from_bytes parses a 520-byte array into a private key.
Format: p (128 bytes) || q (128 bytes) || d (256 bytes) || e (8 bytes), all in big-endian.
Sourcepub fn from_der(der: &[u8]) -> Result<Self, Box<dyn Error>>
pub fn from_der(der: &[u8]) -> Result<Self, Box<dyn Error>>
from_der parses a DER buffer into a private key.
Sourcepub fn from_pem(pem_str: &str) -> Result<Self, Box<dyn Error>>
pub fn from_pem(pem_str: &str) -> Result<Self, Box<dyn Error>>
from_pem parses a PEM string into a private key.
Sourcepub fn to_bytes(&self) -> [u8; 520]
pub fn to_bytes(&self) -> [u8; 520]
to_bytes serializes a private key into a 520-byte array.
Format: p (128 bytes) || q (128 bytes) || d (256 bytes) || e (8 bytes), all in big-endian.
Sourcepub fn public_key(&self) -> PublicKey
pub fn public_key(&self) -> PublicKey
public_key retrieves the public counterpart of the secret key.
Sourcepub fn fingerprint(&self) -> Fingerprint
pub fn fingerprint(&self) -> Fingerprint
fingerprint returns a 256bit unique identified for this key. For RSA, that is the SHA256 hash of the raw (le modulus || le exponent) public key.