@@ -57,7 +57,7 @@ impl PointConversionForm {
57
57
/// Named Curve or Explicit
58
58
///
59
59
/// This type acts as a boolean as to whether the `EcGroup` is named or explicit.
60
- #[ derive( Copy , Clone ) ]
60
+ #[ derive( Copy , Clone , Debug , PartialEq ) ]
61
61
pub struct Asn1Flag ( c_int ) ;
62
62
63
63
impl Asn1Flag {
@@ -294,6 +294,12 @@ impl EcGroupRef {
294
294
}
295
295
}
296
296
297
+ /// Gets the flag determining if the group corresponds to a named curve.
298
+ #[ corresponds( EC_GROUP_get_asn1_flag ) ]
299
+ pub fn asn1_flag ( & mut self ) -> Asn1Flag {
300
+ unsafe { Asn1Flag ( ffi:: EC_GROUP_get_asn1_flag ( self . as_ptr ( ) ) ) }
301
+ }
302
+
297
303
/// Returns the name of the curve, if a name is associated.
298
304
#[ corresponds( EC_GROUP_get_curve_name ) ]
299
305
pub fn curve_name ( & self ) -> Option < Nid > {
@@ -1265,4 +1271,12 @@ mod test {
1265
1271
let group2 = EcGroup :: from_curve_name ( Nid :: X9_62_PRIME239V3 ) . unwrap ( ) ;
1266
1272
assert ! ( !g. is_on_curve( & group2, & mut ctx) . unwrap( ) ) ;
1267
1273
}
1274
+
1275
+ #[ test]
1276
+ #[ cfg( any( boringssl, ossl111, libressl350) ) ]
1277
+ fn asn1_flag ( ) {
1278
+ let mut group = EcGroup :: from_curve_name ( Nid :: X9_62_PRIME256V1 ) . unwrap ( ) ;
1279
+ let flag = group. asn1_flag ( ) ;
1280
+ assert_eq ! ( flag, Asn1Flag :: NAMED_CURVE ) ;
1281
+ }
1268
1282
}
0 commit comments