Skip to content

OpenSSL::BN is used both as a signed and unsigned value, binary encoding should support both #431

@rickmark

Description

@rickmark

A high bit when binary encoding a BN can signal the number is negative. There should be a way when encoding / decoding OpenSSL::BN to indicate if the encoded value is signed or unsigned.

Parsing a unsigned : OpenSSL::BN.new('FF', 16, signed: false) -> .to_i => 255
Parsing a signed : OpenSSL::BN.new('FF', 16, signed: true) -> .negative? => true
Omitting the value for signed: maintains compatibility

Similar parameters may be needed for #to_s as if it is a unsigned with the most significant bit set occurring on the byte boundary it needs an additional "\x00" prefix to disambiguate its sign

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions