22// 2.0, and the BSD License. See the LICENSE file in the root of this repository
33// for complete details.
44
5+ use cryptography_x509:: common:: { Asn1Read , Asn1Write } ;
56use cryptography_x509:: ocsp_req:: { self , OCSPRequest as RawOCSPRequest } ;
6- use cryptography_x509:: { common , oid} ;
7+ use cryptography_x509:: oid;
78use pyo3:: types:: { PyAnyMethods , PyListMethods } ;
89
910use crate :: asn1:: { big_byte_slice_to_py_int, oid_to_py_oid, py_uint_to_big_endian_bytes} ;
1011use crate :: error:: { CryptographyError , CryptographyResult } ;
1112use crate :: x509:: { extensions, ocsp} ;
1213use crate :: { exceptions, types, x509} ;
1314
15+ type ReadRawOCSPRequest < ' a > = RawOCSPRequest < ' a , Asn1Read > ;
1416self_cell:: self_cell!(
1517 struct OwnedOCSPRequest {
1618 owner: pyo3:: Py <pyo3:: types:: PyBytes >,
1719 #[ covariant]
18- dependent: RawOCSPRequest ,
20+ dependent: ReadRawOCSPRequest ,
1921 }
2022) ;
2123
@@ -26,14 +28,7 @@ pub(crate) fn load_der_ocsp_request(
2628) -> CryptographyResult < OCSPRequest > {
2729 let raw = OwnedOCSPRequest :: try_new ( data, |data| asn1:: parse_single ( data. as_bytes ( py) ) ) ?;
2830
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 {
3732 return Err ( CryptographyError :: from (
3833 pyo3:: exceptions:: PyNotImplementedError :: new_err (
3934 "OCSP request contains more than one request" ,
@@ -60,7 +55,6 @@ impl OCSPRequest {
6055 . borrow_dependent ( )
6156 . tbs_request
6257 . request_list
63- . unwrap_read ( )
6458 . clone ( )
6559 . next ( )
6660 . unwrap ( )
@@ -211,13 +205,11 @@ pub(crate) fn create_ocsp_request(
211205 req_cert,
212206 single_request_extensions : None ,
213207 } ] ;
214- let ocsp_req = ocsp_req:: OCSPRequest {
208+ let ocsp_req = ocsp_req:: OCSPRequest :: < Asn1Write > {
215209 tbs_request : ocsp_req:: TBSRequest {
216210 version : 0 ,
217211 requestor_name : None ,
218- request_list : common:: Asn1ReadableOrWritable :: new_write ( asn1:: SequenceOfWriter :: new (
219- & reqs,
220- ) ) ,
212+ request_list : asn1:: SequenceOfWriter :: new ( & reqs) ,
221213 raw_request_extensions : extensions,
222214 } ,
223215 optional_signature : None ,
0 commit comments