1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2014-2019, Linaro Limited
4  */
5 
get_des2_key(const uint8_t ** key,size_t * key_len,uint8_t * tmp)6 static inline void get_des2_key(const uint8_t **key, size_t *key_len,
7 				uint8_t *tmp)
8 {
9 	if (*key_len == 16) {
10 		/*
11 		 * This corresponds to a 2DES key. The 2DES encryption
12 		 * algorithm is similar to 3DES. Both perform and
13 		 * encryption step, then a decryption step, followed
14 		 * by another encryption step (EDE). However 2DES uses
15 		 * the same key for both of the encryption (E) steps.
16 		 */
17 		memcpy(tmp, *key, 16);
18 		memcpy(tmp + 16, *key, 8);
19 		*key = tmp;
20 		*key_len = 24;
21 	}
22 }
23