7807934a27
The encryption definitely uses some standard elliptic curve encryption over binary fields (163 and 233 bits, standard polynomials). It is still unclear how this is used in the actual encryption, the key authentification and derivation do not look standard. Change-Id: I6b9180ff7e6115e1dceca8489e986a02a9ea6fc9
153 lines
8.4 KiB
C
153 lines
8.4 KiB
C
/***************************************************************************
|
|
* __________ __ ___.
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
* \/ \/ \/ \/ \/
|
|
* $Id$
|
|
*
|
|
* Copyright (C) 2012 Amaury Pouly
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
* KIND, either express or implied.
|
|
*
|
|
****************************************************************************/
|
|
#include <stdint.h>
|
|
|
|
uint8_t g_check_block_A_table[1024] =
|
|
{
|
|
0x16, 0x2b, 0x01, 0xe4, 0x0e, 0x3d, 0xc1, 0xdf, 0x0f, 0x35, 0x8f, 0xf5, 0xe2,
|
|
0x48, 0xa0, 0x2e, 0x1c, 0x6a, 0x57, 0xea, 0x6d, 0x9a, 0xe2, 0x03, 0xec, 0xe8,
|
|
0x84, 0x9c, 0x87, 0xca, 0xba, 0xcf, 0xdb, 0x5c, 0x6f, 0xf2, 0x32, 0x72, 0xe9,
|
|
0x50, 0x42, 0x06, 0x1b, 0xe9, 0x9d, 0x8f, 0xa4, 0xff, 0x66, 0x64, 0x59, 0xb7,
|
|
0xd0, 0x15, 0x3c, 0x42, 0x27, 0x25, 0x52, 0x47, 0x83, 0x09, 0x7c, 0x55, 0x1d,
|
|
0xc1, 0x12, 0xfa, 0x7c, 0xaa, 0xf8,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0x29, 0x1f, 0x5c,
|
|
0x57, 0x58, 0xc1, 0xc3, 0xb1, 0xf7, 0xdd, 0x24, 0xd1, 0xaf, 0x13, 0xb1, 0x13,
|
|
0xfb, 0x2a, 0x06, 0xcf, 0xc5, 0x47, 0x58, 0xa0, 0xbd, 0x0c, 0xf2, 0xbb, 0x3d,
|
|
0xcb, 0x01, 0x91, 0xa3, 0xc9, 0x4e, 0xb6, 0x76, 0x35, 0x22, 0xec, 0x84, 0x7c,
|
|
0xe1, 0x0b, 0xb9, 0xc4, 0xae, 0x1b, 0xf6, 0x84, 0xbf, 0x76, 0x40, 0x65, 0x6c,
|
|
0x1f, 0x2a, 0xbe, 0x01, 0x95, 0xbd, 0xaa, 0x09, 0xf2, 0x86, 0x46, 0xb1, 0x52,
|
|
0x6b, 0x24, 0x47, 0x8f, 0x4b, 0x4d, 0x98, 0x95, 0x56, 0x42
|
|
};
|
|
|
|
uint8_t g_decode_B_table[20] =
|
|
{
|
|
0x20, 0xf9, 0xd7, 0x56, 0x30, 0x24, 0x55, 0xa9, 0x7a, 0xd7, 0x25, 0xe5, 0xed,
|
|
0xf8, 0xb4, 0x36, 0x41, 0xc5, 0x51, 0xaf
|
|
};
|
|
|
|
uint32_t g_crypto_table[8] =
|
|
{
|
|
0xefad6126, 0x0a4c9d6e, 0x19c26bf5, 0x149563a4, 0x29f22ff4, 0x7e731af1,
|
|
0x32ba853a, 0x00000172
|
|
};
|
|
|
|
uint32_t g_crypto_table2[8] =
|
|
{
|
|
0x56fae6a3, 0x56e0c110, 0xf18aeb9b, 0x27a8cd9b, 0x555a67c4, 0x19b7f70f,
|
|
0x537dece8, 0x000001db
|
|
};
|
|
|
|
uint32_t g_crypto_key6[8] =
|
|
{
|
|
0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
0x00000000, 0x00000000
|
|
};
|
|
|
|
uint32_t g_crypto_key3[6] =
|
|
{
|
|
0xe8343e36, 0xd4994637, 0xa0991168, 0x86a2d57e, 0xf0eba162, 0x00000003
|
|
};
|
|
|
|
uint32_t g_crypto_key4[6] =
|
|
{
|
|
0x797324f1, 0xb11c5c0c, 0xa2cdd545, 0x71a0094f, 0xd51fbc6c, 0x00000000
|
|
};
|
|
|
|
uint32_t g_atj_ec163_a[6] =
|
|
{
|
|
0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
|
|
};
|
|
|
|
uint32_t g_crypto_key5[6] =
|
|
{
|
|
0x4a3205fd, 0x512f7874, 0x1481eb10, 0xb8c953ca, 0x0a601907, 0x00000002
|
|
};
|
|
|
|
uint32_t g_atj_ec233_a[8] =
|
|
{
|
|
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
};
|