@@ -47,11 +47,8 @@ static VALUE eEC_GROUP;
47
47
static VALUE cEC_POINT ;
48
48
static VALUE eEC_POINT ;
49
49
50
- static ID s_GFp , s_GF2m ;
51
-
52
- static ID ID_uncompressed ;
53
- static ID ID_compressed ;
54
- static ID ID_hybrid ;
50
+ static VALUE sym_GFp , sym_GF2m ;
51
+ static VALUE sym_uncompressed , sym_compressed , sym_hybrid ;
55
52
56
53
static ID id_i_group ;
57
54
@@ -674,19 +671,20 @@ static VALUE ossl_ec_group_initialize(int argc, VALUE *argv, VALUE self)
674
671
break ;
675
672
case 4 :
676
673
if (SYMBOL_P (arg1 )) {
677
- ID id = SYM2ID (arg1 );
678
674
EC_GROUP * (* new_curve )(const BIGNUM * , const BIGNUM * , const BIGNUM * , BN_CTX * ) = NULL ;
679
675
const BIGNUM * p = GetBNPtr (arg2 );
680
676
const BIGNUM * a = GetBNPtr (arg3 );
681
677
const BIGNUM * b = GetBNPtr (arg4 );
682
678
683
- if (id == s_GFp ) {
679
+ if (arg1 == sym_GFp ) {
684
680
new_curve = EC_GROUP_new_curve_GFp ;
681
+ }
685
682
#if !defined(OPENSSL_NO_EC2M )
686
- } else if (id == s_GF2m ) {
683
+ else if (arg1 == sym_GF2m ) {
687
684
new_curve = EC_GROUP_new_curve_GF2m ;
685
+ }
688
686
#endif
689
- } else {
687
+ else {
690
688
ossl_raise (rb_eArgError , "unknown symbol, must be :GFp or :GF2m" );
691
689
}
692
690
@@ -958,37 +956,36 @@ static VALUE ossl_ec_group_set_asn1_flag(VALUE self, VALUE flag_v)
958
956
*/
959
957
static VALUE ossl_ec_group_get_point_conversion_form (VALUE self )
960
958
{
961
- EC_GROUP * group = NULL ;
959
+ EC_GROUP * group ;
962
960
point_conversion_form_t form ;
963
- VALUE ret ;
964
961
965
962
GetECGroup (self , group );
966
963
form = EC_GROUP_get_point_conversion_form (group );
967
964
968
965
switch (form ) {
969
- case POINT_CONVERSION_UNCOMPRESSED : ret = ID_uncompressed ; break ;
970
- case POINT_CONVERSION_COMPRESSED : ret = ID_compressed ; break ;
971
- case POINT_CONVERSION_HYBRID : ret = ID_hybrid ; break ;
972
- default : ossl_raise (eEC_GROUP , "unsupported point conversion form: %d, this module should be updated" , form );
966
+ case POINT_CONVERSION_UNCOMPRESSED :
967
+ return sym_uncompressed ;
968
+ case POINT_CONVERSION_COMPRESSED :
969
+ return sym_compressed ;
970
+ case POINT_CONVERSION_HYBRID :
971
+ return sym_hybrid ;
972
+ default :
973
+ ossl_raise (eEC_GROUP , "unsupported point conversion form: %d, " \
974
+ "this module should be updated" , form );
973
975
}
974
-
975
- return ID2SYM (ret );
976
976
}
977
977
978
978
static point_conversion_form_t
979
979
parse_point_conversion_form_symbol (VALUE sym )
980
980
{
981
- ID id = SYM2ID (sym );
982
-
983
- if (id == ID_uncompressed )
981
+ if (sym == sym_uncompressed )
984
982
return POINT_CONVERSION_UNCOMPRESSED ;
985
- else if (id == ID_compressed )
983
+ if (sym == sym_compressed )
986
984
return POINT_CONVERSION_COMPRESSED ;
987
- else if (id == ID_hybrid )
985
+ if (sym == sym_hybrid )
988
986
return POINT_CONVERSION_HYBRID ;
989
- else
990
- ossl_raise (rb_eArgError , "unsupported point conversion form %+" PRIsVALUE
991
- " (expected :compressed, :uncompressed, or :hybrid)" , sym );
987
+ ossl_raise (rb_eArgError , "unsupported point conversion form %+" PRIsVALUE
988
+ " (expected :compressed, :uncompressed, or :hybrid)" , sym );
992
989
}
993
990
994
991
/*
@@ -1557,12 +1554,12 @@ void Init_ossl_ec(void)
1557
1554
eEC_GROUP = rb_define_class_under (cEC_GROUP , "Error" , eOSSLError );
1558
1555
eEC_POINT = rb_define_class_under (cEC_POINT , "Error" , eOSSLError );
1559
1556
1560
- s_GFp = rb_intern ( "GFp" );
1561
- s_GF2m = rb_intern ( "GF2m" );
1557
+ sym_GFp = ID2SYM ( rb_intern_const ( "GFp" ) );
1558
+ sym_GF2m = ID2SYM ( rb_intern_const ( "GF2m" ) );
1562
1559
1563
- ID_uncompressed = rb_intern ( "uncompressed" );
1564
- ID_compressed = rb_intern ( "compressed" );
1565
- ID_hybrid = rb_intern ( "hybrid" );
1560
+ sym_uncompressed = ID2SYM ( rb_intern_const ( "uncompressed" ) );
1561
+ sym_compressed = ID2SYM ( rb_intern_const ( "compressed" ) );
1562
+ sym_hybrid = ID2SYM ( rb_intern_const ( "hybrid" ) );
1566
1563
1567
1564
rb_define_const (cEC , "NAMED_CURVE" , INT2NUM (OPENSSL_EC_NAMED_CURVE ));
1568
1565
rb_define_const (cEC , "EXPLICIT_CURVE" , INT2NUM (OPENSSL_EC_EXPLICIT_CURVE ));
0 commit comments