We need to take Modulus and exponent from RSA keys. I have created my pubilc key using following methodology. Please let me know how can we take modulus and exponent part from it. I have already read this post.
NSData* tag = [@"com.x.x.x" dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary* attributes =
@{ (id)kSecAttrKeyType: (id)kSecAttrKeyTypeRSA,
(id)kSecAttrKeySizeInBits: @1024,
(id)kSecPrivateKeyAttrs:
@{ (id)kSecAttrIsPermanent: @YES,
(id)kSecAttrApplicationTag: tag,
},
};
CFErrorRef error = NULL;
SecKeyRef privateKey = SecKeyCreateRandomKey((__bridge CFDictionaryRef)attributes,
&error);
if (!privateKey) {
NSError *err = CFBridgingRelease(error);
// Handle the error. . .
}
SecKeyRef publicKey = SecKeyCopyPublicKey(privateKey);
// Now I want modulus and exponent form this publicKey
EDITED :- I have also send base64 string to server but there we are facing quite a issue to find public key ref from base64 string. if someone has done it in c#, you can also help us with this
c# code snippet
const string pKey = "-----key-----"
byte[] publicKeyBytes = Convert.FromBase64String(pKey);
var stream = new MemoryStream(publicKeyBytes);
Asn1Object asn1Object = Asn1Object.FromStream(stream);
Now we need public key component which we are unable to parse. Any help would be great