keys: relying on the type system to ensure keys are 32 byte arrays
This commit is contained in:
@@ -23,11 +23,11 @@ impl KeyPair {
|
||||
KeyPair { private, public }
|
||||
}
|
||||
|
||||
pub fn private_bytes(&self) -> Vec<u8> {
|
||||
self.private.to_bytes().to_vec()
|
||||
pub fn private_bytes(&self) -> [u8; 32] {
|
||||
self.private.to_bytes()
|
||||
}
|
||||
|
||||
pub fn public_bytes(&self) -> Vec<u8> {
|
||||
self.public.to_bytes().to_vec()
|
||||
pub fn public_bytes(&self) -> [u8; 32] {
|
||||
self.public.to_bytes()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,10 +52,10 @@ impl PemStore {
|
||||
);
|
||||
}
|
||||
|
||||
fn write_pem_file(&self, filepath: PathBuf, data: Vec<u8>, tag: String) {
|
||||
fn write_pem_file(&self, filepath: PathBuf, data: [u8; 32], tag: String) {
|
||||
let pem = Pem {
|
||||
tag,
|
||||
contents: data,
|
||||
contents: data.to_vec(),
|
||||
};
|
||||
let key = encode(&pem);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user