|
1 | 1 | //! Agent protocol message structures.
|
2 | 2 |
|
| 3 | +pub mod unparsed; |
| 4 | + |
3 | 5 | use core::str::FromStr;
|
4 | 6 |
|
5 | 7 | use ssh_encoding::{CheckedSum, Decode, Encode, Error as EncodingError, Reader, Writer};
|
6 | 8 | use ssh_key::{
|
7 | 9 | certificate::Certificate, private::KeypairData, public::KeyData, Algorithm, Error, Signature,
|
8 | 10 | };
|
9 | 11 |
|
| 12 | +pub use self::unparsed::*; |
10 | 13 | use super::{
|
11 | 14 | extension::{KeyConstraintExtension, MessageExtension},
|
12 | 15 | PrivateKeyData, ProtoError,
|
@@ -546,7 +549,7 @@ impl Extension {
|
546 | 549 | extension.encode(&mut buffer)?;
|
547 | 550 | Ok(Self {
|
548 | 551 | name: T::NAME.into(),
|
549 |
| - details: Unparsed(buffer), |
| 552 | + details: buffer.into(), |
550 | 553 | })
|
551 | 554 | }
|
552 | 555 |
|
@@ -578,7 +581,7 @@ impl Extension {
|
578 | 581 | extension.encode(&mut buffer)?;
|
579 | 582 | Ok(Self {
|
580 | 583 | name: T::NAME.into(),
|
581 |
| - details: Unparsed(buffer), |
| 584 | + details: buffer.into(), |
582 | 585 | })
|
583 | 586 | }
|
584 | 587 |
|
@@ -627,42 +630,6 @@ impl Encode for Extension {
|
627 | 630 | }
|
628 | 631 | }
|
629 | 632 |
|
630 |
| -/// Generic container for [`Extension`]-specific content |
631 |
| -#[derive(Debug, PartialEq, Clone)] |
632 |
| -pub struct Unparsed(pub Vec<u8>); |
633 |
| - |
634 |
| -impl Unparsed { |
635 |
| - /// Decode unparsed bytes as SSH structures. |
636 |
| - pub fn parse<T>(&self) -> std::result::Result<T, <T as Decode>::Error> |
637 |
| - where |
638 |
| - T: Decode, |
639 |
| - { |
640 |
| - let mut v = &self.0[..]; |
641 |
| - T::decode(&mut v) |
642 |
| - } |
643 |
| -} |
644 |
| - |
645 |
| -impl From<Vec<u8>> for Unparsed { |
646 |
| - fn from(value: Vec<u8>) -> Self { |
647 |
| - Self(value) |
648 |
| - } |
649 |
| -} |
650 |
| - |
651 |
| -impl Encode for Unparsed { |
652 |
| - fn encoded_len(&self) -> ssh_encoding::Result<usize> { |
653 |
| - Ok(self.0.len()) |
654 |
| - } |
655 |
| - |
656 |
| - fn encode(&self, writer: &mut impl Writer) -> ssh_encoding::Result<()> { |
657 |
| - // NOTE: Unparsed fields do not embed a length u32, |
658 |
| - // as the inner Vec<u8> encoding is implementation-defined |
659 |
| - // (usually an Extension) |
660 |
| - writer.write(&self.0[..])?; |
661 |
| - |
662 |
| - Ok(()) |
663 |
| - } |
664 |
| -} |
665 |
| - |
666 | 633 | /// SSH agent protocol request messages.
|
667 | 634 | ///
|
668 | 635 | /// These message types are sent from a client *to* an agent.
|
@@ -1056,7 +1023,7 @@ mod tests {
|
1056 | 1023 | },
|
1057 | 1024 | constraints: vec![KeyConstraint::Extension(Extension {
|
1058 | 1025 | name: "restrict-destination-v00@openssh.com".to_string(),
|
1059 |
| - details: Unparsed( |
| 1026 | + details: Unparsed::from( |
1060 | 1027 | hex!(
|
1061 | 1028 | " 00
|
1062 | 1029 | 0002 6f00 0000 0c00 0000 0000 0000 0000
|
|
0 commit comments