2
2
// 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
3
// for complete details.
4
4
5
+ use cryptography_x509:: common:: { Asn1Read , Asn1Write } ;
5
6
use cryptography_x509:: ocsp_req:: { self , OCSPRequest as RawOCSPRequest } ;
6
- use cryptography_x509:: { common , oid} ;
7
+ use cryptography_x509:: oid;
7
8
use pyo3:: types:: { PyAnyMethods , PyListMethods } ;
8
9
9
10
use crate :: asn1:: { big_byte_slice_to_py_int, oid_to_py_oid, py_uint_to_big_endian_bytes} ;
10
11
use crate :: error:: { CryptographyError , CryptographyResult } ;
11
12
use crate :: x509:: { extensions, ocsp} ;
12
13
use crate :: { exceptions, types, x509} ;
13
14
15
+ type ReadRawOCSPRequest < ' a > = RawOCSPRequest < ' a , Asn1Read > ;
14
16
self_cell:: self_cell!(
15
17
struct OwnedOCSPRequest {
16
18
owner: pyo3:: Py <pyo3:: types:: PyBytes >,
17
19
#[ covariant]
18
- dependent: RawOCSPRequest ,
20
+ dependent: ReadRawOCSPRequest ,
19
21
}
20
22
) ;
21
23
@@ -26,14 +28,7 @@ pub(crate) fn load_der_ocsp_request(
26
28
) -> CryptographyResult < OCSPRequest > {
27
29
let raw = OwnedOCSPRequest :: try_new ( data, |data| asn1:: parse_single ( data. as_bytes ( py) ) ) ?;
28
30
29
- if raw
30
- . borrow_dependent ( )
31
- . tbs_request
32
- . request_list
33
- . unwrap_read ( )
34
- . len ( )
35
- != 1
36
- {
31
+ if raw. borrow_dependent ( ) . tbs_request . request_list . len ( ) != 1 {
37
32
return Err ( CryptographyError :: from (
38
33
pyo3:: exceptions:: PyNotImplementedError :: new_err (
39
34
"OCSP request contains more than one request" ,
@@ -60,7 +55,6 @@ impl OCSPRequest {
60
55
. borrow_dependent ( )
61
56
. tbs_request
62
57
. request_list
63
- . unwrap_read ( )
64
58
. clone ( )
65
59
. next ( )
66
60
. unwrap ( )
@@ -211,13 +205,11 @@ pub(crate) fn create_ocsp_request(
211
205
req_cert,
212
206
single_request_extensions : None ,
213
207
} ] ;
214
- let ocsp_req = ocsp_req:: OCSPRequest {
208
+ let ocsp_req = ocsp_req:: OCSPRequest :: < Asn1Write > {
215
209
tbs_request : ocsp_req:: TBSRequest {
216
210
version : 0 ,
217
211
requestor_name : None ,
218
- request_list : common:: Asn1ReadableOrWritable :: new_write ( asn1:: SequenceOfWriter :: new (
219
- & reqs,
220
- ) ) ,
212
+ request_list : asn1:: SequenceOfWriter :: new ( & reqs) ,
221
213
raw_request_extensions : extensions,
222
214
} ,
223
215
optional_signature : None ,
0 commit comments