Esempio n. 1
0
int atcacert_verify_cert_hw( const atcacert_def_t* cert_def,
                             const uint8_t*        cert,
                             size_t                cert_size,
                             const uint8_t         ca_public_key[64])
{
    int ret = 0;
    uint8_t tbs_digest[32];
    uint8_t signature[64];
    bool is_verified = false;

    if (cert_def == NULL || ca_public_key == NULL || cert == NULL)
        return ATCACERT_E_BAD_PARAMS;

    ret = atcacert_get_tbs_digest(cert_def, cert, cert_size, tbs_digest);
    if (ret != ATCACERT_E_SUCCESS)
        return ret;

    ret = atcacert_get_signature(cert_def, cert, cert_size, signature);
    if (ret != ATCACERT_E_SUCCESS)
        return ret;
    
    ret = atcab_verify_extern(tbs_digest, signature, ca_public_key, &is_verified);
    if (ret != ATCA_SUCCESS)
        return ret;

    return is_verified ? ATCACERT_E_SUCCESS : ATCACERT_E_VERIFY_FAILED;
}
Esempio n. 2
0
int atcacert_verify_response_hw( const uint8_t device_public_key[64],
                                 const uint8_t challenge[32],
                                 const uint8_t response[64])
{
    int ret = 0;
    bool is_verified = false;
    
    if (device_public_key == NULL || challenge == NULL || response == NULL)
        return ATCACERT_E_BAD_PARAMS;

    ret = atcab_verify_extern(challenge, response, device_public_key, &is_verified);
    if (ret != ATCA_SUCCESS)
        return ret;

    return is_verified ? ATCACERT_E_SUCCESS : ATCACERT_E_VERIFY_FAILED;
}
Esempio n. 3
0
/** \brief Verify the signature of the specified message using the specified public key
 *  \param[in] message A pointer to the 32 byte message to be verified
 *  \param[in] signature A pointer to the 64 byte P256 signature to be verified
 *  \param[in] pubkey A pointer to the 64 byte P256 public key used for verificaion
 *  \param[out] verified A pointer to the boolean result of this verify operation
 *  \return ATCA_STATUS
 */
ATCA_STATUS atcatls_verify(const uint8_t *message, const uint8_t *signature, const uint8_t *pubkey, bool *verified)
{
	ATCA_STATUS status = ATCA_SUCCESS;

	do {
		// Check the inputs
		if (message == NULL || signature == NULL || pubkey == NULL || verified == NULL) {
			status = ATCA_BAD_PARAM;
			BREAK(status, "Bad input parameters");
		}
		// Verify the signature of the message
		if ((status = atcab_verify_extern(message, signature, pubkey, verified)) != ATCA_SUCCESS) BREAK(status, "Verify Failed");

	} while (0);

	return status;
}