[null,null,["最后更新时间 (UTC):2025-07-25。"],[[["\u003cp\u003eTink supports using FIPS 140-2 approved cryptographic algorithms with validated implementations like BoringCrypto, although Tink itself is not FIPS validated.\u003c/p\u003e\n"],["\u003cp\u003eA FIPS-only mode in Tink (C++ only) restricts usage to approved algorithms and validated implementations, ensuring only FIPS-compliant keysets are used.\u003c/p\u003e\n"],["\u003cp\u003eIn FIPS-only mode, Tink utilizes BoringCrypto for its validated cryptographic module, with limitations on certain algorithms like AES-CMAC and RSA key sizes.\u003c/p\u003e\n"],["\u003cp\u003eYou can enable FIPS-only mode at compile time with a Bazel build flag or at runtime by calling \u003ccode\u003ecrypto::tink::RestrictToFips()\u003c/code\u003e before any Tink operations.\u003c/p\u003e\n"],["\u003cp\u003eWhen not in FIPS-only mode, Tink can still leverage validated implementations for some algorithms without enforcing restrictions on others.\u003c/p\u003e\n"]]],["Tink, while not FIPS 140-2 validated itself, supports several approved algorithms and can utilize validated modules like BoringCrypto in C++. In FIPS-only mode, enabled at compile or runtime, Tink restricts usage to validated algorithms. It checks for the BoringCrypto module, allowing only FIPS-approved keysets, algorithms and primitives. When using FIPS-only mode, specific algorithms like AES-CMAC are unavailable, and RSA is limited to 3072-bit modulus. Runtime enabling requires calling `crypto::tink::RestrictToFips()` before any Tink operations.\n"],null,["# Use Tink to meet FIPS 140-2 security requirements\n\n| **Note:** This is only supported in the C++ version of Tink at the moment.\n\nTink itself is not\n[FIPS 140-2](https://csrc.nist.gov/publications/detail/fips/140/2/final) validated. However, it supports several FIPS\n140-2 approved algorithms and the underlying implementations *can* utilize\nvalidated cryptographic modules like\n[BoringSSLs BoringCrypto](https://csrc.nist.gov/projects/cryptographic-module-validation-program/certificate/3678). Tink includes a\n[WORKSPACE](https://github.com/tink-crypto/tink-cc/blob/main/third_party/boringssl_fips) for building BoringSSL in FIPS mode.\n\nNote that the workspace gives no inherent guarantee that your use of BoringSSL\nis FIPS compliant. We strongly recommend that you read the official\n[security policy](https://csrc.nist.gov/CSRC/media/projects/cryptographic-module-validation-program/documents/security-policies/140sp3678.pdf) for BoringCrypto.\n\nSupported algorithms\n--------------------\n\nThe following algorithms in Tink are approved according to\n[FIPS 140-2](https://csrc.nist.gov/publications/detail/fips/140/2/final) (see more information at\n[FIPS 140-2 Annex A](https://csrc.nist.gov/CSRC/media/Publications/fips/140/2/final/documents/fips1402annexa.pdf)):\n\n- Authenticated Encryption\n - AES-GCM\n - AES-CTR-HMAC-SHA256\n- MAC\n - HMAC-SHA256\n - AES-CMAC\n- Digital Signatures\n - ECDSA\n - RSA-SSA-PKCS1\n - RSA-SSA-PSS\n\nFIPS-only mode in C++\n---------------------\n\nIf you are required to use FIPS 140-2 approved algorithms and validated\nimplementations, you can build Tink in FIPS-only mode. This restricts\nusage to approved algorithms *and* checks if Tink is utilizing a validated\ncryptographic module.\n\nThis changes the behavior of Tink in the following ways:\n\n- `Register()` functions only register algorithms that have a FIPS validated implementation. This means that you are *only* able to use Keysets for algorithms that use a validated cryptographic module.\n- Tink checks if BoringSSL has been built with the BoringCrypto module. Calls to primitives return an `INTERNAL` error when the module is not available.\n- Using primitives in `subtle/` is restricted to algorithms that utilize a validated cryptographic module.\n\n### BoringCrypto\n\nTink uses [BoringCrypto](https://csrc.nist.gov/projects/cryptographic-module-validation-program/certificate/3678)\nin C++ to provide access to a validated cryptographic module. Its current\nvalidation status imposes the following additional constraints on available\nalgorithms when in FIPS-only mode:\n\n- AES-CMAC has not been validated and is not available\n- RSA-SSA-PKCS1 is restricted to 3072-bit modulus\n- RSA-SSA-PSS is restricted to 3072-bit modulus\n\nTo use the BoringCrypto module with Bazel, you can uncomment the\n`local_repository` definition for `boringssl` in the [C++\nWORKSPACE](https://github.com/google/tink/blob/master/cc/WORKSPACE).\n\n### Enable at compile time\n\nTo build Tink in FIPS-only mode, set a flag at compile time: \n\n bazel build ... --//third_party/tink/cc/config:use_only_fips=True\n\nIf you want to check at runtime whether Tink has been built in FIPS only mode,\nyou can include the header `internal/fips_utils.h` which provides the constant\n`kUseOnlyFips`.\n\nIf you are *not* building Tink in FIPS only mode, it can still utilize\nvalidated implementations for *some* algorithms but not restrict the usage of\nother algorithms.\n\n### Enable at run time\n\nAs an alternative to building Tink in FIPS-only mode, you can call\n`crypto::tink::RestrictToFips()` from `config/tink_fips.h` which sets a flag\nat runtime to enable the restrictions to FIPS primitives.\n\nWARNING: If you use the runtime option, then `crypto::tink::RestrictToFips()`\nmust be called before handling any key material, registering key manager, or\nother Tink functionalities. Additionally, you must ensure that BoringSSL has\nbeen built with the BoringCrypto module, otherwise Tink does not allow you to\nprocess any data."]]