/* ========================================================================= * $File: //dwh/usb_iip/dev/software/dwc_common_port_2/dwc_dh.c $ * $Revision: #3 $ * $Date: 2010/09/28 $ * $Change: 1596182 $ * * Synopsys Portability Library Software and documentation * (hereinafter, "Software") is an Unsupported proprietary work of * Synopsys, Inc. unless otherwise expressly agreed to in writing * between Synopsys and you. * * The Software IS NOT an item of Licensed Software or Licensed Product * under any End User Software License Agreement or Agreement for * Licensed Product with Synopsys or any supplement thereto. You are * permitted to use and redistribute this Software in source and binary * forms, with or without modification, provided that redistributions * of source code must retain this notice. You may not view, use, * disclose, copy or distribute this file or any information contained * herein except pursuant to this license grant from Synopsys. If you * do not agree with this notice, including the disclaimer below, then * you are not authorized to use the Software. * * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS" * BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL * SYNOPSYS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * ========================================================================= */ #ifdef DWC_CRYPTOLIB #ifndef CONFIG_MACH_IPMATE #include "dwc_dh.h" #include "dwc_modpow.h" #ifdef DEBUG /* This function prints out a buffer in the format described in the Association * Model specification. */ static void dh_dump(char *str, void *_num, int len) { uint8_t *num = _num; int i; DWC_PRINTF("%s\n", str); for (i = 0; i < len; i ++) { DWC_PRINTF("%02x", num[i]); if (((i + 1) % 2) == 0) DWC_PRINTF(" "); if (((i + 1) % 26) == 0) DWC_PRINTF("\n"); } DWC_PRINTF("\n"); } #else #define dh_dump(_x...) do {; } while(0) #endif /* Constant g value */ static __u32 dh_g[] = { 0x02000000, }; /* Constant p value */ static __u32 dh_p[] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xA2DA0FC9, 0x34C26821, 0x8B62C6C4, 0xD11CDC80, 0x084E0229, 0x74CC678A, 0xA6BE0B02, 0x229B133B, 0x79084A51, 0xDD04348E, 0xB31995EF, 0x1B433ACD, 0x6D0A2B30, 0x37145FF2, 0x6D35E14F, 0x45C2516D, 0x76B585E4, 0xC67E5E62, 0xE9424CF4, 0x6BED37A6, 0xB65CFF0B, 0xEDB706F4, 0xFB6B38EE, 0xA59F895A, 0x11249FAE, 0xE61F4B7C, 0x51662849, 0x3D5BE4EC, 0xB87C00C2, 0x05BF63A1, 0x3648DA98, 0x9AD3551C, 0xA83F1669, 0x5FCF24FD, 0x235D6583, 0x96ADA3DC, 0x56F3621C, 0xBB528520, 0x0729D59E, 0x6D969670, 0x4E350C67, 0x0498BC4A, 0x086C74F1, 0x7C2118CA, 0x465E9032, 0x3BCE362E, 0x2C779EE3, 0x03860E18, 0xA283279B, 0x8FA207EC, 0xF05DC5B5, 0xC9524C6F, 0xF6CB2BDE, 0x18175895, 0x7C499539, 0xE56A95EA, 0x1826D215, 0x1005FA98, 0x5A8E7215, 0x2DC4AA8A, 0x0D1733AD, 0x337A5004, 0xAB2155A8, 0x64BA1CDF, 0x0485FBEC, 0x0AEFDB58, 0x5771EA8A, 0x7D0C065D, 0x850F97B3, 0xC7E4E1A6, 0x8CAEF5AB, 0xD73309DB, 0xE0948C1E, 0x9D61254A, 0x26D2E3CE, 0x6BEED21A, 0x06FA2FF1, 0x64088AD9, 0x730276D8, 0x646AC83E, 0x182B1F52, 0x0C207B17, 0x5717E1BB, 0x6C5D617A, 0xC0880977, 0xE246D9BA, 0xA04FE208, 0x31ABE574, 0xFC5BDB43, 0x8E10FDE0, 0x20D1824B, 0xCAD23AA9, 0xFFFFFFFF, 0xFFFFFFFF, }; static void dh_swap_bytes(void *_in, void *_out, uint32_t len) { uint8_t *in = _in; uint8_t *out = _out; int i; for (i=0; i