2

I am trying to use Crypt::OpenSSL::EC::EC_POINT::mul() function from Crypt::OpenSSL::EC module. It has such C prototype:

int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx)

And I need to pass NULL, NULL instead of EC_POINT *q, const BIGNUM *m as it made here: https://stackoverflow.com/a/12482384/3090865

But this module has such typemap:

INPUT
BIGNUM
    if( ! SvROK( $arg ) ) { croak( \"argument is not an object\" ); }
    $var = (${type}) SvIV( SvRV( $arg ) );

EC_METHOD
    if( ! SvROK( $arg ) ) { croak( \"argument is not an object\" ); }
    $var = (${type}) SvIV( SvRV( $arg ) );

EC_GROUP
    if( ! SvROK( $arg ) ) { croak( \"argument is not an object\" ); }
    $var = (${type}) SvIV( SvRV( $arg ) );

EC_POINT
    if( ! SvROK( $arg ) ) { croak( \"argument is not an object\" ); }
    $var = (${type}) SvIV( SvRV( $arg ) );

EC_KEY
    if( ! SvROK( $arg ) ) { croak( \"argument is not an object\" ); }
    $var = (${type}) SvIV( SvRV( $arg ) );

So, if i'll pass undef or 0, i'll get "argument is not an object" error. Is it possible to make what I want without changing this module? Maybe I can create NULL-based object somehow?

Community
  • 1
  • 1
Oleg G
  • 925
  • 4
  • 12
  • "I need to pass NULL, NULL instead of EC_POINT *q, const BIGNUM *m" -- This doesn't make sense. What are thinking that the NULL `q` corresponds to in EC terminology? The point at infinity? Same question for `m`? Does NULL correspond to 0? I ask because there may be a better way of trying to do whatever you are trying to do. – TheGreatContini Apr 30 '17 at 22:48

1 Answers1

3

According to the typemap, passing a reference to zero \0 should work:

Crypt::OpenSSL::EC::EC_POINT::mul($group, $r, $n, \0, \0, $ctx);
nwellnhof
  • 32,319
  • 7
  • 89
  • 113