use of com.google.crypto.tink.proto.KeyData in project tink by google.
the class SignaturePemKeysetReader method readKey.
/**
* Reads a single PEM key from {@code reader}. Invalid or unparsable PEM would be ignored
*/
private static Keyset.Key readKey(BufferedReader reader, PemKeyType pemKeyType) throws IOException {
Key key = pemKeyType.readKey(reader);
if (key == null) {
return null;
}
KeyData keyData;
if (key instanceof RSAPublicKey) {
keyData = convertRsaPublicKey(pemKeyType, (RSAPublicKey) key);
} else if (key instanceof ECPublicKey) {
keyData = convertEcPublicKey(pemKeyType, (ECPublicKey) key);
} else {
// TODO(thaidn): support RSA and EC private keys.
return null;
}
return Keyset.Key.newBuilder().setKeyData(keyData).setStatus(KeyStatusType.ENABLED).setOutputPrefixType(// PEM keys don't add any prefix to signatures
OutputPrefixType.RAW).setKeyId(Random.randInt()).build();
}
Aggregations