PointyCastle / pointycastle

Moved into the Bouncy Castle project: https://github.com/bcgit/pc-dart
MIT License
270 stars 76 forks source link

Closed - solved #162

Closed Vanethos closed 5 years ago

Vanethos commented 5 years ago

Using the following:

var cipher = new RSAEngine()
      ..init(false, new PrivateKeyParameter<RSAPrivateKey>(privateKey));
    var encrypted = cipher.process(new Uint8List.fromList(plainText.codeUnits));

gives the error:

RangeError (end): Invalid value: Not in range 0..255, inclusive: 256

Aftet checking the code, I think that this is due to the fact that in BaseAsymmetricBlockCipher we create

var out = new Uint8List(outputBlockSize);

That already had a size of 255, and when in rsa.dart we go into processBlock in _convertOutput the first step is:

final output = utils.encodeBigInt(result);

Whose length is 256, hence it throws the exception.

EDIT: was signing with the cipher value at false.

Other than this, am I correctly signing a message?