RdRand Library
|
00001 /* Copyright © 2012, Intel Corporation. All rights reserved. 00002 00003 Redistribution and use in source and binary forms, with or without 00004 modification, are permitted provided that the following conditions are met: 00005 00006 - Redistributions of source code must retain the above copyright notice, 00007 this list of conditions and the following disclaimer. 00008 - Redistributions in binary form must reproduce the above copyright 00009 notice, this list of conditions and the following disclaimer in the 00010 documentation and/or other materials provided with the distribution. 00011 - Neither the name of Intel Corporation nor the names of its contributors 00012 may be used to endorse or promote products derived from this software 00013 without specific prior written permission. 00014 00015 THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS" AND ANY EXPRESS OR 00016 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00017 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 00018 EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00019 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00020 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 00021 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 00022 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00023 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00024 POSSIBILITY OF SUCH DAMAGE. */ 00025 00033 #ifndef RDRAND_H 00034 #define RDRAND_H 00035 00036 #if __STDC_VERSION__ >= 199901L 00037 #include <stdint.h> 00038 #else 00039 /* MSVC specific */ 00040 typedef unsigned __int16 uint16_t; 00041 typedef unsigned __int32 uint32_t; 00042 typedef unsigned __int64 uint64_t; 00043 #endif 00044 00049 #define RDRAND_SUCCESS 1 00050 00055 #define RDRAND_NOT_READY -1 00056 00060 #define RDRAND_SUPPORTED -2 00061 00065 #define RDRAND_UNSUPPORTED -3 00066 00070 #define RDRAND_SUPPORT_UNKNOWN -4 00071 00088 int rdrand_16(uint16_t* x, int retry); 00089 00106 int rdrand_32(uint32_t* x, int retry); 00107 00124 int rdrand_64(uint64_t* x, int retry); 00125 00133 int rdrand_get_n_64(unsigned int n, uint64_t* x); 00134 00142 int rdrand_get_n_32(unsigned int n, uint32_t* x); 00143 00155 int rdrand_get_bytes(unsigned int n, unsigned char *buffer); 00156 00157 #endif // RDRAND_H