Skip to content

Commit 98683c2

Browse files
committed
pyca/cryptography: avoid direct ASN1_STRING accesses
(includes some unrelated patches for adjusting rust-openssl) pyca/cryptography#13910 openssl/openssl#29117
1 parent add694e commit 98683c2

File tree

3 files changed

+110
-0
lines changed

3 files changed

+110
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
Index: modcargo-crates/openssl-0.10.74/src/ec.rs
2+
--- modcargo-crates/openssl-0.10.74/src/ec.rs.orig
3+
+++ modcargo-crates/openssl-0.10.74/src/ec.rs
4+
@@ -168,7 +168,7 @@ impl EcGroup {
5+
impl EcGroupRef {
6+
/// Places the components of a curve over a prime field in the provided `BigNum`s.
7+
/// The components make up the formula `y^2 mod p = x^3 + ax + b mod p`.
8+
- #[corresponds(EC_GROUP_get_curve_GFp)]
9+
+ #[corresponds(EC_GROUP_get_curve)]
10+
pub fn components_gfp(
11+
&self,
12+
p: &mut BigNumRef,
13+
@@ -177,7 +177,7 @@ impl EcGroupRef {
14+
ctx: &mut BigNumContextRef,
15+
) -> Result<(), ErrorStack> {
16+
unsafe {
17+
- cvt(ffi::EC_GROUP_get_curve_GFp(
18+
+ cvt(ffi::EC_GROUP_get_curve(
19+
self.as_ptr(),
20+
p.as_ptr(),
21+
a.as_ptr(),
22+
@@ -541,7 +541,7 @@ impl EcPointRef {
23+
24+
/// Places affine coordinates of a curve over a prime field in the provided
25+
/// `x` and `y` `BigNum`s
26+
- #[corresponds(EC_POINT_get_affine_coordinates_GFp)]
27+
+ #[corresponds(EC_POINT_get_affine_coordinates)]
28+
pub fn affine_coordinates_gfp(
29+
&self,
30+
group: &EcGroupRef,
31+
@@ -550,7 +550,7 @@ impl EcPointRef {
32+
ctx: &mut BigNumContextRef,
33+
) -> Result<(), ErrorStack> {
34+
unsafe {
35+
- cvt(ffi::EC_POINT_get_affine_coordinates_GFp(
36+
+ cvt(ffi::EC_POINT_get_affine_coordinates(
37+
group.as_ptr(),
38+
self.as_ptr(),
39+
x.as_ptr(),
40+
@@ -586,7 +586,7 @@ impl EcPointRef {
41+
42+
/// Sets affine coordinates of a curve over a prime field using the provided
43+
/// `x` and `y` `BigNum`s
44+
- #[corresponds(EC_POINT_set_affine_coordinates_GFp)]
45+
+ #[corresponds(EC_POINT_set_affine_coordinates)]
46+
pub fn set_affine_coordinates_gfp(
47+
&mut self,
48+
group: &EcGroupRef,
49+
@@ -595,7 +595,7 @@ impl EcPointRef {
50+
ctx: &mut BigNumContextRef,
51+
) -> Result<(), ErrorStack> {
52+
unsafe {
53+
- cvt(ffi::EC_POINT_set_affine_coordinates_GFp(
54+
+ cvt(ffi::EC_POINT_set_affine_coordinates(
55+
group.as_ptr(),
56+
self.as_ptr(),
57+
x.as_ptr(),
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Index: modcargo-crates/openssl-sys-0.9.110/src/handwritten/ec.rs
2+
--- modcargo-crates/openssl-sys-0.9.110/src/handwritten/ec.rs.orig
3+
+++ modcargo-crates/openssl-sys-0.9.110/src/handwritten/ec.rs
4+
@@ -170,6 +170,16 @@ extern "C" {
5+
#[cfg(not(osslconf = "OPENSSL_NO_EC2M"))]
6+
pub fn EC_GF2m_simple_method() -> *const EC_METHOD;
7+
8+
+ #[cfg(any(ossl111, boringssl, libressl, awslc))]
9+
+ pub fn EC_GROUP_get_curve(
10+
+ group: *const EC_GROUP,
11+
+ p: *mut BIGNUM,
12+
+ a: *mut BIGNUM,
13+
+ b: *mut BIGNUM,
14+
+ ctx: *mut BN_CTX,
15+
+ ) -> c_int;
16+
+
17+
+ #[cfg(not(libressl420))]
18+
pub fn EC_GROUP_get_curve_GFp(
19+
group: *const EC_GROUP,
20+
p: *mut BIGNUM,
21+
@@ -187,6 +197,7 @@ extern "C" {
22+
ctx: *mut BN_CTX,
23+
) -> c_int;
24+
25+
+ #[cfg(not(libressl420))]
26+
pub fn EC_POINT_get_affine_coordinates_GFp(
27+
group: *const EC_GROUP,
28+
p: *const EC_POINT,
29+
@@ -195,6 +206,7 @@ extern "C" {
30+
ctx: *mut BN_CTX,
31+
) -> c_int;
32+
33+
+ #[cfg(not(libressl420))]
34+
pub fn EC_POINT_set_affine_coordinates_GFp(
35+
group: *const EC_GROUP,
36+
p: *mut EC_POINT,
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Index: src/_cffi_src/openssl/asn1.py
2+
--- src/_cffi_src/openssl/asn1.py.orig
3+
+++ src/_cffi_src/openssl/asn1.py
4+
@@ -13,12 +13,7 @@ typedef int... time_t;
5+
6+
typedef ... ASN1_INTEGER;
7+
8+
-struct asn1_string_st {
9+
- int length;
10+
- int type;
11+
- unsigned char *data;
12+
- long flags;
13+
-};
14+
+struct asn1_string_st;
15+
16+
typedef struct asn1_string_st ASN1_OCTET_STRING;
17+
typedef struct asn1_string_st ASN1_IA5STRING;

0 commit comments

Comments
 (0)