コード例 #1
0
ExceptionOr<void> CryptoAlgorithmHMAC::platformSign(const CryptoAlgorithmHmacParamsDeprecated& parameters, const CryptoKeyHMAC& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&&)
{
    auto algorithm = commonCryptoHMACAlgorithm(parameters.hash);
    if (!algorithm)
        return Exception { NOT_SUPPORTED_ERR };
    callback(calculateSignature(*algorithm, key.key(), data));
    return { };
}
コード例 #2
0
void CryptoAlgorithmHMAC::platformSign(const CryptoAlgorithmHmacParams& parameters, const CryptoKeyHMAC& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&&, ExceptionCode& ec)
{
    CCHmacAlgorithm algorithm;
    if (!getCommonCryptoHMACAlgorithm(parameters.hash, algorithm)) {
        ec = NOT_SUPPORTED_ERR;
        return;
    }

    Vector<uint8_t> signature = calculateSignature(algorithm, key.key(), data);

    callback(signature);
}
コード例 #3
0
void CryptoAlgorithmHMAC::platformVerify(const CryptoAlgorithmHmacParams& parameters, const CryptoKeyHMAC& key, const CryptoOperationData& expectedSignature, const CryptoOperationData& data, BoolCallback&& callback, VoidCallback&&, ExceptionCode& ec)
{
    CCHmacAlgorithm algorithm;
    if (!getCommonCryptoHMACAlgorithm(parameters.hash, algorithm)) {
        ec = NOT_SUPPORTED_ERR;
        return;
    }

    Vector<uint8_t> signature = calculateSignature(algorithm, key.key(), data);

    // Using a constant time comparison to prevent timing attacks.
    bool result = signature.size() == expectedSignature.second && !constantTimeMemcmp(signature.data(), expectedSignature.first, signature.size());

    callback(result);
}
コード例 #4
0
ExceptionOr<void> CryptoAlgorithmHMAC::platformVerify(const CryptoAlgorithmHmacParamsDeprecated& parameters, const CryptoKeyHMAC& key, const CryptoOperationData& expectedSignature, const CryptoOperationData& data, BoolCallback&& callback, VoidCallback&&)
{
    auto algorithm = commonCryptoHMACAlgorithm(parameters.hash);
    if (!algorithm)
        return Exception { NOT_SUPPORTED_ERR };

    auto signature = calculateSignature(*algorithm, key.key(), data);

    // Using a constant time comparison to prevent timing attacks.
    bool result = signature.size() == expectedSignature.second && !constantTimeMemcmp(signature.data(), expectedSignature.first, signature.size());

    callback(result);

    return { };
}