Class: CryptoToolchain::Tools::LowExponentRSASignatureForgery
- Defined in:
- lib/crypto_toolchain/tools/low_exponent_rsa_signature_forgery.rb
Instance Attribute Summary collapse
-
#keypair ⇒ Object
readonly
Returns the value of attribute keypair.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(message:, keypair:) ⇒ LowExponentRSASignatureForgery
constructor
A new instance of LowExponentRSASignatureForgery.
Constructor Details
#initialize(message:, keypair:) ⇒ LowExponentRSASignatureForgery
Returns a new instance of LowExponentRSASignatureForgery.
5 6 7 8 |
# File 'lib/crypto_toolchain/tools/low_exponent_rsa_signature_forgery.rb', line 5 def initialize(message: , keypair: ) @keypair = keypair @message = end |
Instance Attribute Details
#keypair ⇒ Object (readonly)
Returns the value of attribute keypair.
9 10 11 |
# File 'lib/crypto_toolchain/tools/low_exponent_rsa_signature_forgery.rb', line 9 def keypair @keypair end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
9 10 11 |
# File 'lib/crypto_toolchain/tools/low_exponent_rsa_signature_forgery.rb', line 9 def @message end |
Instance Method Details
#execute ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/crypto_toolchain/tools/low_exponent_rsa_signature_forgery.rb', line 11 def execute digest = CryptoToolchain::Utilities::SHA1.digest() asn = ASN1.fetch(:sha1) max = (keypair.bits / 8) - (asn.bytesize + digest.bytesize + 3) (1..max).reverse_each do |padlen| forged = "\x01\xff\x00#{asn}#{digest}#{0.chr * padlen}". to_number. root(3, round: :up). to_bin_string found = keypair.verify(, signature: forged) return forged if found end raise RuntimeError.new("Couldn't forge a signature") end |