0

I am working with RSA keys and the system requires that I provide the public key modulus in base64 encoding.

I have tried the following openssl rsa -in Key.pem -noout -modulus |sed -e 's/Modulus=//' |xxd -r -p |openssl base64 -out KeyPairPubMod.b64 Where Key.pem is the RSA Private Key, the sed command removes the unneded comment "Modulus=" resulting in a pure hex string. Where it breaks down is in the xxd operation.

I have tried lots of combinations of xxd using intermediate files without success. Running xxd alone with intermediate files I always get a return code of 0 indicating no errors. But nothing is converted.

Here is my input string; 9DDBBD4D44FE8A2263E2EBF1313D095EC77BE9826C6B06A4973464808E12DC91DC1B2F2A8DC52F2CA83A9E02D5508BC04687E1C9658A7DC679D7144589DE0BAAF09873340F098D303D7E88C71D7C2136E7C5EB785C853CAE248B39132CC4FD364AE77594991E6D9D205E7A8659E1707390B10F7238AC3C3D27103A5F3AFCE0588D2144AC981303C8DF9D3F8B6057D6B9E03942096C4D64E005F55047ED335167F1FDA409D0C96BBFF9B951A2AE2062C0591A646F79A96E47B469D372CCFCC479D92D84F0F0AED684F862E9DED9B6166EA9B2AF526096D9AFF31551EDA07D714CFD955EC1E1A0DE806E11C0ED16D38AAD3E6B3E4555CDA492117D072552DEC1BC3DA0232F35EF203C5A1F4EDEF7A85C17595DCB8E8BEFBA81804F37D58D02838F35E253C9E3D97815C1E01DE95C83F625C00254AC373B6EC15E1B36071F9486EAD0ACDF93D9AE9A8A3227041F3A8EA9D990E753A0F45B7AF89737B0A7D6A7A4C1680867EFA6311FA3A25FDFF34B5507BCF9D34B2B6069B3583ABC08B64270979D

What I exppect is the following Base64 string using URL safe encoding: ndu9TUT-iiJj4uvxMT0JXsd76YJsawaklzRkgI4S3JHcGy8qjcUvLKg6ngLVUIvARofhyWWKfcZ51xRFid4LqvCYczQPCY0wPX6Ixx18ITbnxet4XIU8riSLORMsxP02Sud1lJkebZ0gXnqGWeFwc5CxD3I4rDw9JxA6Xzr84FiNIUSsmBMDyN-dP4tgV9a54DlCCWxNZOAF9VBH7TNRZ_H9pAnQyWu_-blRoq4gYsBZGmRvealuR7Rp03LM_MR52S2E8PCu1oT4Yune2bYWbqmyr1Jgltmv8xVR7aB9cUz9lV7B4aDegG4RwO0W04qtPms-RVXNpJIRfQclUt7BvD2gIy817yA8Wh9O3veoXBdZXcuOi--6gYBPN9WNAoOPNeJTyePZeBXB4B3pXIP2JcACVKw3O27BXhs2Bx-UhurQrN-T2a6aijInBB86jqnZkOdToPRbeviXN7Cn1qekwWgIZ--mMR-jol_f80tVB7z500srYGmzWDq8CLZCcJed

  • `openssl base64` does classic (PEM&MIME) base64 not URLsafe, and by default it adds linebreaks; you can turn the latter off with `-A` and change the former with `| tr +/ -_`). With those caveats, your commandline **works for me** on Ubuntu 18.04. What system are you on? What distro or package manager if any are your programs from? What shell do you use, and does it have any aliases or unusual settings? If you do each step with intermediate files which one is the first to fail? – dave_thompson_085 Jul 23 '23 at 07:04
  • I strongly suspect that my problem is with the distro. I'm using Cygwin 10.0-19045. – hkc94501 Jul 25 '23 at 02:31

0 Answers0