I have a public key which is:
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwLuOqAUq1NsH2MKox4qH
WzulOu7/3tcO4OAw35uNoTwHOYteNNS/JdyOYE6zCwR2po/cndoeVohGQaUskF7m
/Uuawc/uRYlngQIKYU5UIhrbhG2LR21uti+mGivF5WnRnSCn7W3ffkZa56kC8y4X
scR+erpni1D2rSvFQVZQnYkC8CVm8Wxv1cNJNwjRCOl14tHva+XayURLeU8rj1Cu
ovD/XN4+Pvy4pEh4eRW0ujDYerCavsbZsK16iw/kJWAN2/do3XvrQgS6gubSsQkb
yFfHZ5Jc1dhYxHwhVjUZzO36NJyKIJQg303ktvxYrGGsOdfaSPkrUj3q1qVYpLQI
iQIDAQAB
-----END PUBLIC KEY-----
I would like to add the string “+++ATRIUM+++” to it using openssl. Here is some advice I received, but I am having trouble figuring out how to do it:
You need to produce a pair of RSA keys where the public key, encoded in base64, contains “+++ATRIUM+++”. Without delving too much into the details, the public key contains ( n ) and ( e ), plus some padding bytes due to ASN.1 serialization (which is quite complicated). So, the “promotional string” must appear either in ( n ) or in ( e ) when represented in base64.
Between ( n ) and ( e ), it’s ( e ) that is easier to control: indeed, it can be freely chosen when creating the key pair. But be careful! It must be odd.
Base64 encoding complicates matters (don’t hesitate to read the corresponding Wikipedia page). In fact, each 6-bit packet is encoded into one character. So, 3 initial bytes (24 bits) are represented by 4 characters. If the “promotional string” does not begin at a position that is a multiple of 3 in the starting key, then it will straddle different ASCII characters and will not appear correctly. One potential solution is to add one or two bytes BEFORE in ( e ).
The public key after modification must remain valid.
I tried to add +++ATRIUM+++ to the public key but as expected it do not work.
Seb65789 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1