| Line No. | Rev | Author | Line |
|---|---|---|---|
| 1 | 32 | kaklik | /********************************************************************* |
| 2 | * |
||
| 3 | * Secure Random Number Generator Headers |
||
| 4 | * |
||
| 5 | ********************************************************************* |
||
| 6 | * FileName: Random.h |
||
| 7 | * Dependencies: None |
||
| 8 | * Processor: PIC18, PIC24F, PIC24H, dsPIC30F, dsPIC33F, PIC32 |
||
| 9 | * Compiler: Microchip C32 v1.05 or higher |
||
| 10 | * Microchip C30 v3.12 or higher |
||
| 11 | * Microchip C18 v3.30 or higher |
||
| 12 | * HI-TECH PICC-18 PRO 9.63PL2 or higher |
||
| 13 | * Company: Microchip Technology, Inc. |
||
| 14 | * |
||
| 15 | * Software License Agreement |
||
| 16 | * |
||
| 17 | * Copyright (C) 2002-2009 Microchip Technology Inc. All rights |
||
| 18 | * reserved. |
||
| 19 | * |
||
| 20 | * Microchip licenses to you the right to use, modify, copy, and |
||
| 21 | * distribute: |
||
| 22 | * (i) the Software when embedded on a Microchip microcontroller or |
||
| 23 | * digital signal controller product ("Device") which is |
||
| 24 | * integrated into Licensee's product; or |
||
| 25 | * (ii) ONLY the Software driver source files ENC28J60.c, ENC28J60.h, |
||
| 26 | * ENCX24J600.c and ENCX24J600.h ported to a non-Microchip device |
||
| 27 | * used in conjunction with a Microchip ethernet controller for |
||
| 28 | * the sole purpose of interfacing with the ethernet controller. |
||
| 29 | * |
||
| 30 | * You should refer to the license agreement accompanying this |
||
| 31 | * Software for additional information regarding your rights and |
||
| 32 | * obligations. |
||
| 33 | * |
||
| 34 | * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT |
||
| 35 | * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT |
||
| 36 | * LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A |
||
| 37 | * PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL |
||
| 38 | * MICROCHIP BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR |
||
| 39 | * CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF |
||
| 40 | * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS |
||
| 41 | * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE |
||
| 42 | * THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER |
||
| 43 | * SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT |
||
| 44 | * (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE. |
||
| 45 | * |
||
| 46 | * |
||
| 47 | * Author Date Comment |
||
| 48 | *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
||
| 49 | * Elliott Wood 5/09/07 Original (Rev 1.0) |
||
| 50 | ********************************************************************/ |
||
| 51 | |||
| 52 | #ifndef __RANDOM_H |
||
| 53 | #define __RANDOM_H |
||
| 54 | |||
| 55 | #if defined(STACK_USE_RANDOM) |
||
| 56 | |||
| 57 | #define STACK_USE_SHA1 |
||
| 58 | |||
| 59 | //Entropy is generated as follows: |
||
| 60 | // 1. For every packet received, the last byte of the remote |
||
| 61 | // MAC address and the four bytes of TickGet() are added |
||
| 62 | // to a SHA-1 Hash (the seed) |
||
| 63 | // 2. Every time a random byte is requested, the hash is |
||
| 64 | // calculated and the hash sum is hashed into the seed. |
||
| 65 | // 3. Up to 20 bytes are returned from this hash sum before |
||
| 66 | // a new hash is calculated. |
||
| 67 | // 4. Every time new entropy is added, the remaining random |
||
| 68 | // output is discarded and new random bytes will be |
||
| 69 | // generated upon future calls to RandomGet(). |
||
| 70 | |||
| 71 | void RandomInit(void); |
||
| 72 | BYTE RandomGet(void); |
||
| 73 | void RandomAdd(BYTE data); |
||
| 74 | |||
| 75 | #endif |
||
| 76 | |||
| 77 | #endif |
Powered by WebSVN v2.8.3