Skip to content

Wrong PEM encoding: RSAPrivateKey.exponent returns the private exponent #4

@elsamuko

Description

@elsamuko

See here:

var publicExponent = ASN1Integer(privateKey.exponent);

I used this helper function to calculate the public exponent:

// inverse of private exponent -> public exponent
//! \sa rsa_key_generator.dart
static BigInt getPublicExponent(RSAPrivateKey privateKey) {
  var pSub1 = (privateKey.p - BigInt.one);
  var qSub1 = (privateKey.q - BigInt.one);
  var phi = (pSub1 * qSub1);
  var publicExponent = privateKey.exponent.modInverse(phi);
  return publicExponent;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions