Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- require "base64"
- require "openssl"
- # For private key:
- # version Version,
- # modulus INTEGER, -- n
- # publicExponent INTEGER, -- e
- # privateExponent INTEGER, -- d
- # prime1 INTEGER, -- p
- # prime2 INTEGER, -- q
- # exponent1 INTEGER, -- d mod (p-1)
- # exponent2 INTEGER, -- d mod (q-1)
- # coefficient INTEGER, -- (inverse of q) mod p
- #
- # where n=pq, d=(inverse of e) mod n
- # For public key:
- # modulus INTEGER, -- n
- # publicExponent INTEGER, -- e
- def print_asn(d, prefix="")
- case d
- when OpenSSL::ASN1::Sequence
- puts "#{prefix}Sequence:"
- d.value.each do |item|
- print_asn item, "#{prefix} "
- end
- when OpenSSL::ASN1::Integer
- puts "#{prefix}#{d.value}"
- else
- raise
- end
- end
- data = STDIN.read
- data = Base64.decode64(data)
- print_asn OpenSSL::ASN1.decode(data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement