Closed InoMurko closed 7 years ago
If you load Erlang records from public_key module:
Erlang/OTP 19 [erts-8.1] [source-77fb4f8] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] Eshell V8.1 (abort with ^G) 1> rr(public_key). ['AAControls','ACClearAttrs','AccessDescription', 'Algorithm','AlgorithmIdentifier', 'AlgorithmIdentifierPKCS-10','AlgorithmIdentifierPKCS-8', 'AlgorithmIdentifierPKCS5v2-0','AlgorithmIdentifierPKSC-7', 'AlgorithmNull','AnotherName','AttCertValidityPeriod', 'Attribute','AttributeCertificate', 'AttributeCertificateInfo','AttributePKCS-10', 'AttributePKCS-7','AttributeTypeAndValue', 'Attributes_SETOF', 'Attributes_SETOF_valuesWithContext_SETOF', 'AuthorityKeyIdentifier','BasicConstraints', 'BuiltInDomainDefinedAttribute','BuiltInStandardAttributes', 'Certificate','CertificateList','CertificationRequest', 'CertificationRequestInfo', 'CertificationRequestInfo_attributes_SETOF'|...] 2> #'RSAPublicKey'{}. #'RSAPublicKey'{modulus = undefined, publicExponent = undefined} 3> #'RSAPrivateKey'{}. #'RSAPrivateKey'{version = undefined,modulus = undefined, publicExponent = undefined,privateExponent = undefined, prime1 = undefined,prime2 = undefined,exponent1 = undefined, exponent2 = undefined,coefficient = undefined, otherPrimeInfos = asn1_NOVALUE}
You can see that modulus is always on index 1 and publicExponent on index 2. This is important because if you use crypto:private_decrypt/4 or crypto:public_encrypt/4 you need to pass the keys as a list [e, n, d, p1, p2, e1, e2, c] or [e, n].
@ntrepid8 feedback?
Yup, sorry for delay. Busy week at work. Will address before end of day tomorrow at the latest.
This was a good catch. Thanks for the PR.
This is published on hex.pm as version 0.2.1.
0.2.1
If you load Erlang records from public_key module:
You can see that modulus is always on index 1 and publicExponent on index 2. This is important because if you use crypto:private_decrypt/4 or crypto:public_encrypt/4 you need to pass the keys as a list [e, n, d, p1, p2, e1, e2, c] or [e, n].