JannePeltonen replied on github web page:

platform/linux-generic/odp_crypto.c
line 139
@@ -165,24 +192,51 @@ null_crypto_routine(odp_crypto_op_param_t *param 
ODP_UNUSED,
        return ODP_CRYPTO_ALG_ERR_NONE;
 }
 
+/* Mimic new OpenSSL 1.1.y API */
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+static HMAC_CTX *HMAC_CTX_new(void)
+{
+       HMAC_CTX *ctx = malloc(sizeof(*ctx));
+
+       HMAC_CTX_init(ctx);
+       return ctx;
+}
+
+static void HMAC_CTX_free(HMAC_CTX *ctx)
+{
+       HMAC_CTX_cleanup(ctx);
+       free(ctx);
+}
+#endif
+
 static
-void packet_hmac_calculate(HMAC_CTX *ctx,
-                          odp_crypto_op_param_t *param,
-                          odp_crypto_generic_session_t *session,
-                          uint8_t *hash)
+void packet_hmac(odp_crypto_op_param_t *param,
+                odp_crypto_generic_session_t *session,
+                uint8_t *hash)
 {
+       HMAC_CTX *ctx = local.ctx[session->idx].hmac;
        odp_packet_t pkt = param->out_pkt;
        uint32_t offset = param->auth_range.offset;
        uint32_t len   = param->auth_range.length;
 
        ODP_ASSERT(offset + len <= odp_packet_len(pkt));
 
-       HMAC_Init_ex(ctx,
-                    session->auth.key,
-                    session->auth.key_length,
-                    session->auth.evp_md,
-                    NULL);
+       if (!IS_VALID(session, hmac, local.id)) {
+               SET_VALID(session, hmac, local.id);
+               HMAC_Init_ex(ctx,
+                            session->auth.key,
+                            session->auth.key_length,
+                            session->auth.evp_md,
+                            NULL);
+       } else {
+               HMAC_Init_ex(ctx,
+                            NULL,
+                            session->auth.key_length,


Comment:
Why is this needed here? The key length was already set. If this is because of 
some OpenSSL weirdness, an explanatory comment would be nice.


> JannePeltonen wrote
> The cipher_valid and hmac_valid bits are not cleared at session allocation, 
> so they can be left to what they were in an old and freed session that 
> occupied the same memory slot. 


>> Bill Fischofer(Bill-Fischofer-Linaro) wrote:
>> Then I'd follow "Maxim's rule" and do the renames as a separate follow-on PR.


>>> muvarov wrote
>>> I prefer the rule that new code goes in in clean way. Even if rest of the 
>>> code used old rules.


>>>> Bill Fischofer(Bill-Fischofer-Linaro) wrote:
>>>> That makes sense to me.


>>>>> Dmitry Eremin-Solenikov(lumag) wrote:
>>>>> Then I would prefer to use names w/o underscore for now and to change all 
>>>>> of them later.


>>>>>> Bill Fischofer(Bill-Fischofer-Linaro) wrote:
>>>>>> I don't see the need to do that at this point as these are internal 
>>>>>> routines anyway. That type of restructure might be something to consider 
>>>>>> for Caterpillar. 


>>>>>>> Dmitry Eremin-Solenikov(lumag) wrote:
>>>>>>> Hmm. The rest of init/term functions do not have such prefix. Should we 
>>>>>>> change them?


>>>>>>>> Dmitry Eremin-Solenikov(lumag) wrote:
>>>>>>>> No, `sizeof uint32_t`


>>>>>>>>> muvarov wrote
>>>>>>>>> `_odp_crypto_term_local`


>>>>>>>>>> muvarov wrote
>>>>>>>>>> `_odp_crypto_init_local`


>>>>>>>>>>> muvarov wrote
>>>>>>>>>>> is 32 everywhere MAX_SESSIONS?


https://github.com/Linaro/odp/pull/342#discussion_r157490855
updated_at 2017-12-18 14:00:46

Reply via email to