Fix default value for KBKDF LLEN parameter 76/292476/1
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Mon, 8 May 2023 18:43:51 +0000 (20:43 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Mon, 8 May 2023 18:50:04 +0000 (20:50 +0200)
Change the default value of CKMC_PARAM_KBKDF_LLEN from 0 to 32
according to API description.

Change-Id: I972d95227b047394c5f59addc9242d43c9c68be7

src/manager/crypto/sw-backend/internals.cpp

index 9796b2e..26a5f33 100644 (file)
@@ -1040,7 +1040,7 @@ Data deriveKBKDF(const RawBuffer &secret, const CryptoAlgorithm &alg)
        RawBuffer label, context, fixed;
        KbkdfCounterLocation counterLocation;
        KdfPrf prf;
-       size_t length, rlenBits = 32, llenBits = 0, tmp;
+       size_t length, rlenBits = 32, llenBits = 32, tmp;
        bool hasLabel = alg.getParam(ParamName::KBKDF_LABEL, label);
        bool hasContext = alg.getParam(ParamName::KBKDF_CONTEXT, context);
        bool hasFixed = alg.getParam(ParamName::KBKDF_FIXED_INPUT, fixed);
@@ -1048,7 +1048,7 @@ Data deriveKBKDF(const RawBuffer &secret, const CryptoAlgorithm &alg)
        alg.getParam(ParamName::KDF_PRF, prf);
        alg.getParam(ParamName::KDF_LEN, length);
        alg.getParam(ParamName::KBKDF_RLEN, rlenBits);
-       alg.getParam(ParamName::KBKDF_LLEN, llenBits);
+       bool hasLLen = alg.getParam(ParamName::KBKDF_LLEN, llenBits);
        bool useSeparator = !alg.getParam(ParamName::KBKDF_NO_SEPARATOR, tmp);
 
        const EVP_MD* md = nullptr;
@@ -1068,7 +1068,7 @@ Data deriveKBKDF(const RawBuffer &secret, const CryptoAlgorithm &alg)
 
        RawBuffer key;
        if (hasFixed) {
-               if (hasLabel || hasContext || !useSeparator || llenBits > 0 ||
+               if (hasLabel || hasContext || !useSeparator || hasLLen ||
                        counterLocation == KbkdfCounterLocation::MIDDLE_FIXED)
                        ThrowErr(Exc::Crypto::InputParam, "Unexpected parameters for fixed input mode.");