Functions | |
void | fsl_shw_permute1_bytes (const uint8_t *key, uint8_t *permuted_key, int key_count) |
Variables | |
static const uint8_t | pc1 [] |
static const int | bytebit [] |
This file implements the function fsl_shw_permute1_bytes().
The code was lifted from crypto++ v5.5.2, which is public domain code. The code to handle words instead of bytes was extensively modified from the byte version and then converted to handle one to three keys at once.
void fsl_shw_permute1_bytes | ( | const uint8_t * | key, | |
uint8_t * | permuted_key, | |||
int | key_count | |||
) |
Convert a 3-key 3DES key into the first-permutation 168-bit version.
This is the format of the input key:
BIT: |191 128|127 64|63 0| BYTE: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | KEY: | 0 | 1 | 2 |
This is the format of the output key:
BIT: |167 112|111 56|55 0| BYTE: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | KEY: | 1 | 2 | 3 |
[in] | key | bytes of 3DES key |
[out] | permuted_key | 21 bytes of permuted key |
[in] | key_count | How many DES keys (2 or 3) |
const int bytebit[] [static] |
{ 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }
bit 0 is left-most in byte
const uint8_t pc1[] [static] |
{ 56, 48, 40, 32, 24, 16, 8, 0, 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 60, 52, 44, 36, 28, 20, 12, 4, 27, 19, 11, 3, }
permuted choice table (key)
Note that this table has had one subtracted from each element so that the code doesn't have to do it.
© Freescale Semiconductor, Inc., 2007.
All rights reserved. Freescale Confidential Proprietary NDA Required |
![]() |