Lines Matching refs:alg
439 * This size can be calculated with #PSA_HASH_LENGTH(\c alg) where
440 * \c alg is the HMAC algorithm or the underlying hash algorithm. */
797 #define PSA_ALG_IS_VENDOR_DEFINED(alg) \
798 (((alg) & PSA_ALG_VENDOR_FLAG) != 0)
802 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
804 * \return 1 if \p alg is a hash algorithm, 0 otherwise.
805 * This macro may return either 0 or 1 if \p alg is not a supported
808 #define PSA_ALG_IS_HASH(alg) \
809 (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_HASH)
813 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
815 * \return 1 if \p alg is a MAC algorithm, 0 otherwise.
816 * This macro may return either 0 or 1 if \p alg is not a supported
819 #define PSA_ALG_IS_MAC(alg) \
820 (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_MAC)
824 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
826 * \return 1 if \p alg is a symmetric cipher algorithm, 0 otherwise.
827 * This macro may return either 0 or 1 if \p alg is not a supported
830 #define PSA_ALG_IS_CIPHER(alg) \
831 (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_CIPHER)
836 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
838 * \return 1 if \p alg is an AEAD algorithm, 0 otherwise.
839 * This macro may return either 0 or 1 if \p alg is not a supported
842 #define PSA_ALG_IS_AEAD(alg) \
843 (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_AEAD)
848 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
850 * \return 1 if \p alg is an asymmetric signature algorithm, 0 otherwise.
851 * This macro may return either 0 or 1 if \p alg is not a supported
854 #define PSA_ALG_IS_SIGN(alg) \
855 (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_SIGN)
860 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
862 * \return 1 if \p alg is an asymmetric encryption algorithm, 0 otherwise.
863 * This macro may return either 0 or 1 if \p alg is not a supported
866 #define PSA_ALG_IS_ASYMMETRIC_ENCRYPTION(alg) \
867 (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION)
871 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
873 * \return 1 if \p alg is a key agreement algorithm, 0 otherwise.
874 * This macro may return either 0 or 1 if \p alg is not a supported
877 #define PSA_ALG_IS_KEY_AGREEMENT(alg) \
878 (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_KEY_AGREEMENT)
882 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
884 * \return 1 if \p alg is a key derivation algorithm, 0 otherwise.
885 * This macro may return either 0 or 1 if \p alg is not a supported
888 #define PSA_ALG_IS_KEY_DERIVATION(alg) \
889 (((alg) & PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_KEY_DERIVATION)
899 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
901 * \return 1 if \p alg is a key stretching / password hashing algorithm, 0
902 * otherwise. This macro may return either 0 or 1 if \p alg is not a
905 #define PSA_ALG_IS_KEY_DERIVATION_STRETCHING(alg) \
906 (PSA_ALG_IS_KEY_DERIVATION(alg) && \
907 (alg) & PSA_ALG_KEY_DERIVATION_STRETCHING_FLAG)
977 * an algorithm \c alg, #PSA_ALG_IS_HASH_AND_SIGN(\c alg) is true.
1007 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
1009 * \return 1 if \p alg is an HMAC algorithm, 0 otherwise.
1010 * This macro may return either 0 or 1 if \p alg is not a supported
1013 #define PSA_ALG_IS_HMAC(alg) \
1014 (((alg) & (PSA_ALG_CATEGORY_MASK | PSA_ALG_MAC_SUBCATEGORY_MASK)) == \
1143 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
1145 * \return 1 if \p alg is a MAC algorithm based on a block cipher, 0 otherwise.
1146 * This macro may return either 0 or 1 if \p alg is not a supported
1149 #define PSA_ALG_IS_BLOCK_CIPHER_MAC(alg) \
1150 (((alg) & (PSA_ALG_CATEGORY_MASK | PSA_ALG_MAC_SUBCATEGORY_MASK)) == \
1162 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
1164 * \return 1 if \p alg is a stream cipher algorithm, 0 otherwise.
1165 * This macro may return either 0 or 1 if \p alg is not a supported
1168 #define PSA_ALG_IS_STREAM_CIPHER(alg) \
1169 (((alg) & (PSA_ALG_CATEGORY_MASK | PSA_ALG_CIPHER_STREAM_FLAG)) == \
1249 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
1251 * \return 1 if \p alg is an AEAD algorithm which is an AEAD mode based on
1253 * This macro may return either 0 or 1 if \p alg is not a supported
1256 #define PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) \
1257 (((alg) & (PSA_ALG_CATEGORY_MASK | PSA_ALG_AEAD_FROM_BLOCK_FLAG)) == \
1419 #define PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) \
1420 (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_PKCS1V15_SIGN_BASE)
1467 * \param alg An algorithm value or an algorithm policy wildcard.
1469 * \return 1 if \p alg is of the form
1473 * This macro may return either 0 or 1 if \p alg is not
1476 #define PSA_ALG_IS_RSA_PSS_STANDARD_SALT(alg) \
1477 (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_PSS_BASE)
1481 * \param alg An algorithm value or an algorithm policy wildcard.
1483 * \return 1 if \p alg is of the form
1487 * This macro may return either 0 or 1 if \p alg is not
1490 #define PSA_ALG_IS_RSA_PSS_ANY_SALT(alg) \
1491 (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_PSS_ANY_SALT_BASE)
1498 * \param alg An algorithm value or an algorithm policy wildcard.
1500 * \return 1 if \p alg is of the form
1505 * This macro may return either 0 or 1 if \p alg is not
1508 #define PSA_ALG_IS_RSA_PSS(alg) \
1509 (PSA_ALG_IS_RSA_PSS_STANDARD_SALT(alg) || \
1510 PSA_ALG_IS_RSA_PSS_ANY_SALT(alg))
1571 #define PSA_ALG_IS_ECDSA(alg) \
1572 (((alg) & ~PSA_ALG_HASH_MASK & ~PSA_ALG_ECDSA_DETERMINISTIC_FLAG) == \
1574 #define PSA_ALG_ECDSA_IS_DETERMINISTIC(alg) \
1575 (((alg) & PSA_ALG_ECDSA_DETERMINISTIC_FLAG) != 0)
1576 #define PSA_ALG_IS_DETERMINISTIC_ECDSA(alg) \
1577 (PSA_ALG_IS_ECDSA(alg) && PSA_ALG_ECDSA_IS_DETERMINISTIC(alg))
1578 #define PSA_ALG_IS_RANDOMIZED_ECDSA(alg) \
1579 (PSA_ALG_IS_ECDSA(alg) && !PSA_ALG_ECDSA_IS_DETERMINISTIC(alg))
1612 #define PSA_ALG_IS_HASH_EDDSA(alg) \
1613 (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_HASH_EDDSA_BASE)
1667 #define PSA_ALG_IS_VENDOR_HASH_AND_SIGN(alg) 0
1678 * \param alg An algorithm identifier (value of type psa_algorithm_t).
1680 * \return 1 if alg is a signature algorithm that can be used to sign a
1681 * hash. 0 if alg is a signature algorithm that can only be used
1682 * to sign a message. 0 if alg is not a signature algorithm.
1683 * This macro can return either 0 or 1 if alg is not a
1686 #define PSA_ALG_IS_SIGN_HASH(alg) \
1687 (PSA_ALG_IS_RSA_PSS(alg) || PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) || \
1688 PSA_ALG_IS_ECDSA(alg) || PSA_ALG_IS_HASH_EDDSA(alg) || \
1689 PSA_ALG_IS_VENDOR_HASH_AND_SIGN(alg))
1694 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
1696 * \return 1 if alg is a signature algorithm that can be used to sign a
1697 * message. 0 if \p alg is a signature algorithm that can only be used
1698 * to sign an already-calculated hash. 0 if \p alg is not a signature
1699 * algorithm. This macro can return either 0 or 1 if \p alg is not a
1702 #define PSA_ALG_IS_SIGN_MESSAGE(alg) \
1703 (PSA_ALG_IS_SIGN_HASH(alg) || (alg) == PSA_ALG_PURE_EDDSA)
1715 * `psa_sign_message(key, alg, input, ...)` is equivalent to
1717 * psa_hash_compute(PSA_ALG_SIGN_GET_HASH(alg), input, ..., hash, ...);
1718 * psa_sign_hash(key, alg, hash, ..., signature, ...);
1725 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
1727 * \return 1 if \p alg is a hash-and-sign algorithm, 0 otherwise.
1728 * This macro may return either 0 or 1 if \p alg is not a supported
1731 #define PSA_ALG_IS_HASH_AND_SIGN(alg) \
1732 (PSA_ALG_IS_SIGN_HASH(alg) && \
1733 ((alg) & PSA_ALG_HASH_MASK) != 0)
1743 * \param alg A signature algorithm (\c PSA_ALG_XXX value such that
1744 * #PSA_ALG_IS_SIGN(\p alg) is true).
1746 * \return The underlying hash algorithm if \p alg is a hash-and-sign
1748 * \return 0 if \p alg is a signature algorithm that does not
1750 * \return Unspecified if \p alg is not a signature algorithm or
1753 #define PSA_ALG_SIGN_GET_HASH(alg) \
1754 (PSA_ALG_IS_HASH_AND_SIGN(alg) ? \
1755 ((alg) & PSA_ALG_HASH_MASK) | PSA_ALG_CATEGORY_HASH : \
1786 #define PSA_ALG_IS_RSA_OAEP(alg) \
1787 (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_OAEP_BASE)
1788 #define PSA_ALG_RSA_OAEP_GET_HASH(alg) \
1789 (PSA_ALG_IS_RSA_OAEP(alg) ? \
1790 ((alg) & PSA_ALG_HASH_MASK) | PSA_ALG_CATEGORY_HASH : \
1827 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
1829 * \return 1 if \c alg is an HKDF algorithm, 0 otherwise.
1830 * This macro may return either 0 or 1 if \c alg is not a supported
1833 #define PSA_ALG_IS_HKDF(alg) \
1834 (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_HKDF_BASE)
1878 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
1880 * \return 1 if \c alg is an HKDF-Extract algorithm, 0 otherwise.
1881 * This macro may return either 0 or 1 if \c alg is not a supported
1884 #define PSA_ALG_IS_HKDF_EXTRACT(alg) \
1885 (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_HKDF_EXTRACT_BASE)
1920 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
1922 * \return 1 if \c alg is an HKDF-Expand algorithm, 0 otherwise.
1923 * This macro may return either 0 or 1 if \c alg is not a supported
1926 #define PSA_ALG_IS_HKDF_EXPAND(alg) \
1927 (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_HKDF_EXPAND_BASE)
1933 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
1935 * \return 1 if \c alg is any HKDF type algorithm, 0 otherwise.
1936 * This macro may return either 0 or 1 if \c alg is not a supported
1939 #define PSA_ALG_IS_ANY_HKDF(alg) \
1940 (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_HKDF_BASE || \
1941 ((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_HKDF_EXTRACT_BASE || \
1942 ((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_HKDF_EXPAND_BASE)
1976 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
1978 * \return 1 if \c alg is a TLS-1.2 PRF algorithm, 0 otherwise.
1979 * This macro may return either 0 or 1 if \c alg is not a supported
1982 #define PSA_ALG_IS_TLS12_PRF(alg) \
1983 (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_TLS12_PRF_BASE)
2046 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
2048 * \return 1 if \c alg is a TLS-1.2 PSK to MS algorithm, 0 otherwise.
2049 * This macro may return either 0 or 1 if \c alg is not a supported
2052 #define PSA_ALG_IS_TLS12_PSK_TO_MS(alg) \
2053 (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_TLS12_PSK_TO_MS_BASE)
2112 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
2114 * \return 1 if \c alg is a PBKDF2-HMAC algorithm, 0 otherwise.
2115 * This macro may return either 0 or 1 if \c alg is not a supported
2118 #define PSA_ALG_IS_PBKDF2_HMAC(alg) \
2119 (((alg) & ~PSA_ALG_HASH_MASK) == PSA_ALG_PBKDF2_HMAC_BASE)
2157 #define PSA_ALG_KEY_AGREEMENT_GET_KDF(alg) \
2158 (((alg) & PSA_ALG_KEY_DERIVATION_MASK) | PSA_ALG_CATEGORY_KEY_DERIVATION)
2160 #define PSA_ALG_KEY_AGREEMENT_GET_BASE(alg) \
2161 (((alg) & PSA_ALG_KEY_AGREEMENT_MASK) | PSA_ALG_CATEGORY_KEY_AGREEMENT)
2171 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
2173 * \return 1 if \p alg is a raw key agreement algorithm, 0 otherwise.
2174 * This macro may return either 0 or 1 if \p alg is not a supported
2177 #define PSA_ALG_IS_RAW_KEY_AGREEMENT(alg) \
2178 (PSA_ALG_IS_KEY_AGREEMENT(alg) && \
2179 PSA_ALG_KEY_AGREEMENT_GET_KDF(alg) == PSA_ALG_CATEGORY_KEY_DERIVATION)
2181 #define PSA_ALG_IS_KEY_DERIVATION_OR_AGREEMENT(alg) \
2182 ((PSA_ALG_IS_KEY_DERIVATION(alg) || PSA_ALG_IS_KEY_AGREEMENT(alg)))
2199 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
2201 * \return 1 if \c alg is a finite field Diffie-Hellman algorithm, 0 otherwise.
2202 * This macro may return either 0 or 1 if \c alg is not a supported
2205 #define PSA_ALG_IS_FFDH(alg) \
2206 (PSA_ALG_KEY_AGREEMENT_GET_BASE(alg) == PSA_ALG_FFDH)
2242 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
2244 * \return 1 if \c alg is an elliptic curve Diffie-Hellman algorithm,
2246 * This macro may return either 0 or 1 if \c alg is not a supported
2249 #define PSA_ALG_IS_ECDH(alg) \
2250 (PSA_ALG_KEY_AGREEMENT_GET_BASE(alg) == PSA_ALG_ECDH)
2257 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
2259 * \return 1 if \c alg is a wildcard algorithm encoding.
2260 * \return 0 if \c alg is a non-wildcard algorithm encoding (suitable for
2262 * \return This macro may return either 0 or 1 if \c alg is not a supported
2265 #define PSA_ALG_IS_WILDCARD(alg) \
2266 (PSA_ALG_IS_HASH_AND_SIGN(alg) ? \
2267 PSA_ALG_SIGN_GET_HASH(alg) == PSA_ALG_ANY_HASH : \
2268 PSA_ALG_IS_MAC(alg) ? \
2269 (alg & PSA_ALG_MAC_AT_LEAST_THIS_LENGTH_FLAG) != 0 : \
2270 PSA_ALG_IS_AEAD(alg) ? \
2271 (alg & PSA_ALG_AEAD_AT_LEAST_THIS_LENGTH_FLAG) != 0 : \
2272 (alg) == PSA_ALG_ANY_HASH)
2276 * \param alg An algorithm identifier (value of type #psa_algorithm_t).
2278 * \return The underlying hash algorithm if alg is a composite algorithm that
2281 * \return \c 0 if alg is not a composite algorithm that uses a hash.
2283 #define PSA_ALG_GET_HASH(alg) \
2284 (((alg) & 0x000000ff) == 0 ? ((psa_algorithm_t) 0) : 0x02000000 | ((alg) & 0x000000ff))