POLICY.CONF(5)
π policy.conf(5) β openCryptoki π
okay bestie, sit down, hydrate, and let me tell you about policy.conf(5) β the openCryptoki config file that decides what your crypto is allowed to do. it's giving bouncer-at-the-club energy and honestly? iconic.
β¨ NAME β¨
policy.conf β the configuration file for openCryptoki policies. yes that's the whole name, short and slay.
πΈ DESCRIPTION πΈ
openCryptoki reads a policy configuration file living at:
/etc/opencryptoki/policy.conf
what does it do? it restricts openCryptoki's operations down to a specific set of allowed operations. basically it lets users lock things down: restrict keys to a minimal cryptographic strength, and restrict supported elliptic curves, mechanisms, MGFs, KDFs, or PRFs. gatekeeping, but make it cryptographic π
π SYNTAX π
the file starts with a version specification of the form version policy-0, and then comes the policy constraints. order matters, bestie, we don't freestyle this.
a policy constraint assigns a value to a configuration key. and the syntax depends on the value of the key β so let's go one by one:
πͺ strength
this key defines the minimal required strength for keys, and digest and signature sizes. it corresponds to the definition in /etc/opencryptoki/strength.conf. valid values are 0, 112, 128, 192, and 256. the special value 0 allows every key and arbitrary size of digests and signatures (chaos mode, lowkey). the format is a simple assignment:
strength = number
if other values are used, they are rounded up to the next supported value. and values greater than 256 are rounded down to 256. no cap, the rounding is doing its own thing.
π§ allowedmechs
this key specifies a list of mechanisms that are allowed by this policy. the list should contain a comma-separated list of CKM_ constants supported by openCryptoki. the list goes inside brackets:
allowedmechs ( mech1, mech2 )
Note: this key is optional. if it's not present, all mechanisms are allowed. but if you provide an empty list, then no mechanism would be allowed. (empty list = zero, not "all", don't get got.)
π¦ allowedcurves
this key specifies a list of allowed elliptic curves. keys that do not belong to any of the allowed curves cannot be created or used. the list has the same format as the allowedmechs key:
allowedcurves ( curve1, curve2 )
valid curve names are:
BRAINPOOL_P160R1BRAINPOOL_P160T1BRAINPOOL_P192R1BRAINPOOL_P192T1BRAINPOOL_P224R1BRAINPOOL_P224T1BRAINPOOL_P256R1BRAINPOOL_P256T1BRAINPOOL_P320R1BRAINPOOL_P320T1BRAINPOOL_P384R1BRAINPOOL_P384T1BRAINPOOL_P512R1BRAINPOOL_P512T1PRIME192V1SECP224R1PRIME256V1SECP384R1SECP521R1SECP256K1CURVE25519CURVE448ED25519ED448
Note: this key is optional. if not present, all curves are allowed. an empty list allows no curve. β οΈ
π allowedmgfs
this key specifies the allowed Message Generation Functions (MGFs) for use in RSA OAEP and RSA PSS. the value is a list of CKG_ constants supported by openCryptoki. same format as allowedmechs:
allowedmgfs ( mgf1, mgf2 )
Note: optional again, bestie. if not present, all MGFs are allowed. an empty list allows no MGF.
π§ allowedkdfs
this key specifies the allowed Key Derivation Functions (KDFs) for use in ECDH key derivation and Kyber KEM. the value is a list of CKD_ constants supported by openCryptoki. and yes, same format as allowedmechs:
allowedkdfs ( kdf1, kdf2 )
Note: optional, you know the drill. if not present, all KDFs are allowed. an empty list allows no KDF.
π allowedprfs
this key specifies the allowed Pseudo-Random Functions (PRFs) for use in PKCS #5 PBKDF. the value is a list of PRFs. currently, the only supported value is CKP_PKCS5_PBKD2_HMAC_SHA256 CKP_PKCS5_PBKD2_HMAC_SHA512, which leads to the list:
allowedprfs ( CKP_PKCS5_PBKD2_HMAC_SHA512,
CKP_PKCS5_PBKD2_HMAC_SHA256 )
Note: optional, as always. if not present, all PRFs are allowed. an empty list allows no PRF.
π NOTES π
okay here's the part where you actually pay attention, because the vibes get serious.
the policy configuration file has to be owned by root:pkcs11 and have mode 0640. otherwise, openCryptoki will return CKR_FUNCTION_FAILED on C_Initialize and log the reason into syslog. so set those perms, bestie, it's not optional.
the pound sign ('#') is used to indicate a comment. both the comment character and any text after it, up to the end of the line, are ignored. the comment character can be used at the beginning of a line (including before the file version specification), after the strength value, after a comma, and before and after the bracket. flexible queen π
since the policy indirectly refers to a strength configuration, a strength configuration has to exist and be valid. if no strength configuration exists, no policy will be enforced. and if an existing policy configuration is invalid, openCryptoki cannot be used. periodt.
π token store tea π
openCryptoki uses some cryptographic operations to store token objects. these operations have to be allowed by the policy. which operations are needed depends on the token store format and the token (since the ICSF Token as a remote token uses different crypto operations to store its management data):
- FIPS compliant format β token stores in the FIPS compliant format need the mechanisms
CKM_AES_KEY_GEN,CKM_AES_KEY_WRAP,CKM_AES_GCM,CKM_PKCS5_PBKD2, the PRFCKP_PKCS5_PBKD2_HMAC_SHA512, and must allow256bit AES keys. - legacy format β token stores in legacy format need the mechanisms
CKM_DES3_KEY_GEN,CKM_DES3_CBC,CKM_AES_KEY_GEN,CKM_AES_CBC,CKM_SHA1,CKM_MD5and must allow 2-key TDES keys (80bit symmetric keys with64bit signatures). - ICSF Token store β
CKM_AES_KEY_GEN,CKM_AES_CBC,CKM_SHA1,CKM_MD5CKM_PKCS5_PBKD2, the PRFCKP_PKCS5_PBKD2_HMAC_SHA256, and must allow256bit AES keys.
tokens cannot be loaded if their token store format is not supported by the policy. if a token cannot be loaded, a message is printed into syslog detailing the policy violation. to fix this problem, make sure the token format is allowed by your policy (either by satisfying above constraints or by temporarily removing /etc/opencryptoki/policy.conf) and migrate your token store, e.g., to the FIPS-compliant format. you got this π«Ά
π SEE ALSO π
strength.conf(5)opencryptoki(7)pkcstok_migrate(1)/usr/share/doc/opencryptoki/policy-example.conf
and that's the whole page, bestie! this was openCryptoki 3.27.0, dated September 2021 β main character documentation energy, no cap. go forth and configure responsibly πβ¨
π¦ where this page comes from
- centos-stream 10: opencryptoki 3.27.0-1.el10 Β· CPL-1.0
- centos-stream 9: opencryptoki 3.27.0-1.el9 Β· CPL-1.0
- fedora 44: opencryptoki 3.27.0-1.fc44 Β· CPL-1.0
- opensuse-leap 16.0: openCryptoki 3.27.0-160000.2.1 Β· CPL-1.0
- opensuse-leap 16.0: openCryptoki 3.27.0-160000.2.1 Β· CPL-1.0
- opensuse-leap 16.0: openCryptoki 3.27.0-160000.2.1 Β· CPL-1.0
- opensuse-leap 16.0: openCryptoki 3.27.0-160000.2.1 Β· CPL-1.0
- ubuntu stonking: opencryptoki 3.27.0+dfsg-0ubuntu2 Β· CPL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms