@@ -7,7 +7,7 @@ use core::marker::PhantomData;
77use crate :: { PemReader , pem:: PemLabel } ;
88
99#[ cfg( doc) ]
10- use crate :: { Length , Tag } ;
10+ use crate :: { ErrorKind , Length , Tag } ;
1111
1212#[ cfg( feature = "alloc" ) ]
1313use alloc:: boxed:: Box ;
@@ -34,11 +34,24 @@ pub trait Decode<'a>: Sized + 'a {
3434 }
3535
3636 /// Parse `Self` from the provided DER-encoded byte slice.
37+ ///
38+ /// Returns [`ErrorKind::TrailingData`] if message is incomplete.
3739 fn from_der ( bytes : & ' a [ u8 ] ) -> Result < Self , Self :: Error > {
3840 let mut reader = SliceReader :: new ( bytes) ?;
3941 let result = Self :: decode ( & mut reader) ?;
4042 Ok ( reader. finish ( result) ?)
4143 }
44+
45+ /// Parse `Self` from the provided DER-encoded byte slice.
46+ ///
47+ /// Returns remaining byte slice, without checking for incomplete message.
48+ fn from_der_partial ( bytes : & ' a [ u8 ] ) -> Result < ( Self , & ' a [ u8 ] ) , Self :: Error > {
49+ let mut reader = SliceReader :: new ( bytes) ?;
50+ let result = Self :: decode ( & mut reader) ?;
51+
52+ let remaining = reader. remaining ( ) ?;
53+ Ok ( ( result, remaining) )
54+ }
4255}
4356
4457impl < ' a , T > Decode < ' a > for T
0 commit comments