public static ArrayList retrievePublicKeys()

in java/remoteprovisioning/CertificateRequestDeserializer.java [195:228]


  public static ArrayList<PublicKey> retrievePublicKeys(
      byte[] serializedMacedKeysToSign, byte[] macKey) throws CborException, CryptoException {
    MAC0Message macedKeysToSign = new MAC0Message();
    try {
      macedKeysToSign.DecodeFromCBORObject(CBORObject.DecodeFromBytes(serializedMacedKeysToSign));
      if (!macedKeysToSign.Validate(macKey)) {
        throw new CryptoException(
            "MAC on the public keys failed to validate",
            CryptoException.PUBLIC_KEYS_MAC_VERIFICATION_FAILED);
      }
    } catch (CoseException e) {
      throw new CborException("Couldn't decode MACed keys", e, CborException.DESERIALIZATION_ERROR);
    }

    ArrayList<PublicKey> deserializedPublicKeys = new ArrayList<>();
    CBORObject serializedPublicKeys = CBORObject.DecodeFromBytes(macedKeysToSign.GetContent());
    if (serializedPublicKeys.getType() != CBORType.Array) {
      throw new CborException(
          "KeysToCertify Type Wrong",
          CBORType.Array,
          serializedPublicKeys.getType(),
          CborException.TYPE_MISMATCH);
    }
    for (int i = 0; i < serializedPublicKeys.size(); i++) {
      try {
        OneKey key = new OneKey(serializedPublicKeys.get(i));
        deserializedPublicKeys.add(CryptoUtil.oneKeyToP256PublicKey(key));
      } catch (CoseException e) {
        throw new CborException(
            "Failure to deserialize public keys", e, CborException.DESERIALIZATION_ERROR);
      }
    }
    return deserializedPublicKeys;
  }