X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=lib%2Fcrypto_backend%2Fcrypto_backend_internal.h;h=9b1cc6960b30c4176352093285db2af68b6a1df4;hb=6497abd1df88001eb1f45f7348534911b33d05b5;hp=9d1bfb26487d0461a54690a9e2864f8f864a1b03;hpb=f7fc3bb4e50cce23dd95111b246b6e034537e2cf;p=platform%2Fupstream%2Fcryptsetup.git diff --git a/lib/crypto_backend/crypto_backend_internal.h b/lib/crypto_backend/crypto_backend_internal.h index 9d1bfb2..9b1cc69 100644 --- a/lib/crypto_backend/crypto_backend_internal.h +++ b/lib/crypto_backend/crypto_backend_internal.h @@ -1,8 +1,8 @@ /* * crypto backend implementation * - * Copyright (C) 2010-2021 Red Hat, Inc. All rights reserved. - * Copyright (C) 2010-2021 Milan Broz + * Copyright (C) 2010-2023 Red Hat, Inc. All rights reserved. + * Copyright (C) 2010-2023 Milan Broz * * This file is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -23,7 +23,6 @@ #include "crypto_backend.h" -#if USE_INTERNAL_PBKDF2 /* internal PBKDF2 implementation */ int pkcs5_pbkdf2(const char *hash, const char *P, size_t Plen, @@ -31,7 +30,6 @@ int pkcs5_pbkdf2(const char *hash, unsigned int c, unsigned int dkLen, char *DK, unsigned int hash_block_size); -#endif /* Argon2 implementation wrapper */ int argon2(const char *type, const char *password, size_t password_length, @@ -60,4 +58,18 @@ int crypt_bitlk_decrypt_key_kernel(const void *key, size_t key_length, const char *iv, size_t iv_length, const char *tag, size_t tag_length); +/* Internal implementation for constant time memory comparison */ +static inline int crypt_internal_memeq(const void *m1, const void *m2, size_t n) +{ + const unsigned char *_m1 = (const unsigned char *) m1; + const unsigned char *_m2 = (const unsigned char *) m2; + unsigned char result = 0; + size_t i; + + for (i = 0; i < n; i++) + result |= _m1[i] ^ _m2[i]; + + return result; +} + #endif /* _CRYPTO_BACKEND_INTERNAL_H */