@@ -4,13 +4,16 @@ use crate::{Error, Result, Version};
4
4
use core:: fmt;
5
5
use der:: {
6
6
asn1:: { AnyRef , BitStringRef , ContextSpecific , OctetStringRef } ,
7
- BytesRef , Decode , DecodeValue , Encode , EncodeValue , Header , Length , Reader , Sequence , TagMode ,
8
- TagNumber , Writer ,
7
+ Decode , DecodeValue , Encode , EncodeValue , Header , Length , Reader , Sequence , TagMode , TagNumber ,
8
+ Writer ,
9
9
} ;
10
10
use spki:: AlgorithmIdentifier ;
11
11
12
12
#[ cfg( feature = "alloc" ) ]
13
- use der:: { asn1:: Any , BytesOwned , SecretDocument } ;
13
+ use {
14
+ alloc:: boxed:: Box ,
15
+ der:: { asn1:: Any , SecretDocument } ,
16
+ } ;
14
17
15
18
#[ cfg( feature = "encryption" ) ]
16
19
use {
@@ -129,7 +132,7 @@ impl<Params, Key> PrivateKeyInfo<Params, Key> {
129
132
impl < ' a , Params , Key > PrivateKeyInfo < Params , Key >
130
133
where
131
134
Params : der:: Choice < ' a > + Encode ,
132
- Key : TryFrom < & ' a [ u8 ] , Error = der :: Error > + AsRef < [ u8 ] > ,
135
+ Key : From < & ' a [ u8 ] > + AsRef < [ u8 ] > ,
133
136
{
134
137
/// Encrypt this private key using a symmetric encryption key derived
135
138
/// from the provided password.
@@ -186,7 +189,7 @@ where
186
189
impl < ' a , Params , Key > DecodeValue < ' a > for PrivateKeyInfo < Params , Key >
187
190
where
188
191
Params : der:: Choice < ' a > + Encode ,
189
- Key : TryFrom < & ' a [ u8 ] , Error = der :: Error > ,
192
+ Key : From < & ' a [ u8 ] > ,
190
193
{
191
194
fn decode_value < R : Reader < ' a > > (
192
195
reader : & mut R ,
@@ -203,7 +206,7 @@ where
203
206
. map ( |bs| {
204
207
bs. as_bytes ( )
205
208
. ok_or_else ( || der:: Tag :: BitString . value_error ( ) )
206
- . and_then ( Key :: try_from )
209
+ . map ( Key :: from )
207
210
} )
208
211
. transpose ( ) ?;
209
212
@@ -256,14 +259,14 @@ where
256
259
impl < ' a , Params , Key > Sequence < ' a > for PrivateKeyInfo < Params , Key >
257
260
where
258
261
Params : der:: Choice < ' a > + Encode ,
259
- Key : TryFrom < & ' a [ u8 ] , Error = der :: Error > + AsRef < [ u8 ] > ,
262
+ Key : From < & ' a [ u8 ] > + AsRef < [ u8 ] > ,
260
263
{
261
264
}
262
265
263
266
impl < ' a , Params , Key > TryFrom < & ' a [ u8 ] > for PrivateKeyInfo < Params , Key >
264
267
where
265
268
Params : der:: Choice < ' a > + Encode ,
266
- Key : TryFrom < & ' a [ u8 ] , Error = der :: Error > + AsRef < [ u8 ] > ,
269
+ Key : From < & ' a [ u8 ] > + AsRef < [ u8 ] > ,
267
270
{
268
271
type Error = Error ;
269
272
@@ -290,7 +293,7 @@ where
290
293
impl < ' a , Params , Key > TryFrom < PrivateKeyInfo < Params , Key > > for SecretDocument
291
294
where
292
295
Params : der:: Choice < ' a > + Encode ,
293
- Key : TryFrom < & ' a [ u8 ] , Error = der :: Error > + AsRef < [ u8 ] > ,
296
+ Key : From < & ' a [ u8 ] > + AsRef < [ u8 ] > ,
294
297
{
295
298
type Error = Error ;
296
299
@@ -303,7 +306,7 @@ where
303
306
impl < ' a , Params , Key > TryFrom < & PrivateKeyInfo < Params , Key > > for SecretDocument
304
307
where
305
308
Params : der:: Choice < ' a > + Encode ,
306
- Key : TryFrom < & ' a [ u8 ] , Error = der :: Error > + AsRef < [ u8 ] > ,
309
+ Key : From < & ' a [ u8 ] > + AsRef < [ u8 ] > ,
307
310
{
308
311
type Error = Error ;
309
312
@@ -352,12 +355,12 @@ where
352
355
}
353
356
}
354
357
355
- /// [`PrivateKeyInfo`] with [`AnyRef`] algorithm parameters, and [`BytesRef`] key.
356
- pub type PrivateKeyInfoRef < ' a > = PrivateKeyInfo < AnyRef < ' a > , BytesRef < ' a > > ;
358
+ /// [`PrivateKeyInfo`] with [`AnyRef`] algorithm parameters, and `&[u8]` key.
359
+ pub type PrivateKeyInfoRef < ' a > = PrivateKeyInfo < AnyRef < ' a > , & ' a [ u8 ] > ;
357
360
358
- /// [`PrivateKeyInfo`] with [`Any`] algorithm parameters, and [`BytesOwned`] key.
361
+ /// [`PrivateKeyInfo`] with [`Any`] algorithm parameters, and `Box<[u8]>` key.
359
362
#[ cfg( feature = "alloc" ) ]
360
- pub type PrivateKeyInfoOwned = PrivateKeyInfo < Any , BytesOwned > ;
363
+ pub type PrivateKeyInfoOwned = PrivateKeyInfo < Any , Box < [ u8 ] > > ;
361
364
362
365
#[ cfg( feature = "alloc" ) ]
363
366
mod allocating {
0 commit comments