keys: relying on the type system to ensure keys are 32 byte arrays

This commit is contained in:
Dave Hrycyszyn
2019-12-17 14:48:20 +00:00
parent a42dd55320
commit 74e0fb849b
2 changed files with 6 additions and 6 deletions
+4 -4
View File
@@ -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()
}
}
+2 -2
View File
@@ -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);