File: 0004-Bump-rust-asn1-version-13098.patch

package info (click to toggle)
python-cryptography 45.0.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,400 kB
  • sloc: python: 52,617; java: 319; makefile: 161
file content (90 lines) | stat: -rw-r--r-- 3,000 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
From: Alex Gaynor <alex.gaynor@gmail.com>
Date: Fri, 20 Jun 2025 16:44:42 -0400
Subject: Bump rust-asn1 version (#13098)

---
 src/rust/cryptography-x509/src/common.rs | 28 +++++++++++++++++++++++++++-
 src/rust/cryptography-x509/src/name.rs   |  3 +++
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/src/rust/cryptography-x509/src/common.rs b/src/rust/cryptography-x509/src/common.rs
index a19910d..53d1f0b 100644
--- a/src/rust/cryptography-x509/src/common.rs
+++ b/src/rust/cryptography-x509/src/common.rs
@@ -243,7 +243,14 @@ impl<'a> asn1::Asn1Readable<'a> for RawTlv<'a> {
 }
 impl asn1::Asn1Writable for RawTlv<'_> {
     fn write(&self, w: &mut asn1::Writer<'_>) -> asn1::WriteResult {
-        w.write_tlv(self.tag, move |dest| dest.push_slice(self.value))
+        w.write_tlv(self.tag, Some(self.value.len()), move |dest| {
+            dest.push_slice(self.value)
+        })
+    }
+
+    fn encoded_length(&self) -> Option<usize> {
+        // TODO: we're missing an API to make this easy.
+        None
     }
 }
 
@@ -304,6 +311,13 @@ impl<T: asn1::SimpleAsn1Writable, U: asn1::SimpleAsn1Writable> asn1::SimpleAsn1W
             Asn1ReadableOrWritable::Write(v) => U::write_data(v, w),
         }
     }
+
+    fn data_length(&self) -> Option<usize> {
+        match self {
+            Asn1ReadableOrWritable::Read(v) => T::data_length(v),
+            Asn1ReadableOrWritable::Write(v) => U::data_length(v),
+        }
+    }
 }
 
 pub trait Asn1Operation {
@@ -579,6 +593,10 @@ impl asn1::SimpleAsn1Writable for UnvalidatedVisibleString<'_> {
     fn write_data(&self, _: &mut asn1::WriteBuf) -> asn1::WriteResult {
         unimplemented!();
     }
+
+    fn data_length(&self) -> Option<usize> {
+        None
+    }
 }
 
 /// A BMPString ASN.1 element, where it is stored as a UTF-8 string in memory.
@@ -598,6 +616,10 @@ impl asn1::SimpleAsn1Writable for Utf8StoredBMPString<'_> {
         }
         Ok(())
     }
+
+    fn data_length(&self) -> Option<usize> {
+        Some(self.0.encode_utf16().count() * 2)
+    }
 }
 
 #[derive(Clone)]
@@ -638,6 +660,10 @@ impl<T: asn1::Asn1Writable> asn1::Asn1Writable for WithTlv<'_, T> {
     fn write(&self, w: &mut asn1::Writer<'_>) -> asn1::WriteResult<()> {
         self.value.write(w)
     }
+
+    fn encoded_length(&self) -> Option<usize> {
+        self.value.encoded_length()
+    }
 }
 
 impl<T: PartialEq> PartialEq for WithTlv<'_, T> {
diff --git a/src/rust/cryptography-x509/src/name.rs b/src/rust/cryptography-x509/src/name.rs
index 078bca1..17634de 100644
--- a/src/rust/cryptography-x509/src/name.rs
+++ b/src/rust/cryptography-x509/src/name.rs
@@ -40,6 +40,9 @@ impl asn1::SimpleAsn1Writable for UnvalidatedIA5String<'_> {
     fn write_data(&self, dest: &mut asn1::WriteBuf) -> asn1::WriteResult {
         dest.push_slice(self.0.as_bytes())
     }
+    fn data_length(&self) -> Option<usize> {
+        Some(self.0.len())
+    }
 }
 
 #[derive(asn1::Asn1Read, asn1::Asn1Write, PartialEq, Eq, Hash)]