I am able to export a public key generated in iOS and convert it to base64:
var dataPtr:Unmanaged<AnyObject>?
let query: [String:AnyObject] = [
kSecClass: kSecClassKey,
kSecAttrApplicationTag: "com.example.site.public",
kSecReturnData: kCFBooleanTrue
]
let qResult = SecItemCopyMatching(query, &dataPtr)
// error handling with `qResult` ...
let publicKeyData = dataPtr!.takeRetainedValue() as NSData
// convert to Base64 string
let base64PublicKey = publicKeyData.base64EncodedStringWithOptions(nil)
I also was able to send it to my LAMP server. Now I'm trying to figure out how to use it as a public key over there.
I tried:
$keydata = base64decode($_GET['base64PublicKey']);
$res = gnupg_init();
$info = gnupg_import($res,$keydata);
print_r($info);
Is this the right direction? I'm aware that the size of the data is 270, not the same as block size of the key. I'm somewhat new to PKI, any help would be appreciated.