Commit ee5e408
authored
crypto-common: add
Adds a companion trait to `KeyInit*` for exporting a key to a byte array
sized according to `KeySizeUser`.
This is needed when generating e.g. asymmetric secret keys types using
the `Generate` trait and it returns an actual key type (e.g.
`SigningKey`, `DecryptionKey`, `DecapsulationKey`) as opposed to its
serialized byte representation.
This PR also shows another use case for it: there's currently a gap in
the `kem` crate around serialization where you can generically go from
`Decapsulate::encapsulator` to the associated encapsulation key for a
KEM, but there is currently no generic way to serialize it.
It adds `TryKeyInit` and `KeyExport` bounds to `kem::Encapsulate`,
because as the public key component we should always be able to
serialize/deserialize it.
(NOTE: happy to split the `kem` changes out, that would probably be for
the best, but I thought it would help illustrate the use case)KeyExport trait (#2213)1 parent f57ec3b commit ee5e408
2 files changed
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
159 | 165 | | |
160 | 166 | | |
161 | 167 | | |
| |||
0 commit comments