diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2023-03-14 16:07:13 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2023-03-14 16:48:14 +0100 |
commit | 7914568a309b7692bdcb9cebd1b8820c34e71c87 (patch) | |
tree | 5e585d9b4ec779e720d798345f7bacab0e26d5b9 /openpgp/src/crypto/mpi.rs | |
parent | 67819944a69a7faba0d1cf400facaffce6da01d5 (diff) |
openpgp: Immediately create ProtectedMPIs for secrets.
- Avoid creating an MPI first, as this may leak the secrets.
Diffstat (limited to 'openpgp/src/crypto/mpi.rs')
-rw-r--r-- | openpgp/src/crypto/mpi.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/openpgp/src/crypto/mpi.rs b/openpgp/src/crypto/mpi.rs index 961398c5..a5fa4f63 100644 --- a/openpgp/src/crypto/mpi.rs +++ b/openpgp/src/crypto/mpi.rs @@ -329,6 +329,15 @@ pub struct ProtectedMPI { } assert_send_and_sync!(ProtectedMPI); +impl From<&[u8]> for ProtectedMPI { + fn from(m: &[u8]) -> Self { + let value = Protected::from(MPI::trim_leading_zeros(m)); + ProtectedMPI { + value, + } + } +} + impl From<Vec<u8>> for ProtectedMPI { fn from(m: Vec<u8>) -> Self { let value = Protected::from(MPI::trim_leading_zeros(&m)); |