packages feed

entropy 0.2.2.3 → 0.2.2.4

raw patch · 4 files changed

+72/−25 lines, 4 filesdep ~basesetup-changed

Dependency ranges changed: base

Files

LICENSE view
@@ -1,30 +1,30 @@-Copyright (c) 2013, Thomas M. DuBuisson+Copyright (c) Thomas DuBuisson  All rights reserved.  Redistribution and use in source and binary forms, with or without-modification, are permitted provided that the following conditions are met:+modification, are permitted provided that the following conditions+are met: -    * Redistributions of source code must retain the above copyright-      notice, this list of conditions and the following disclaimer.+1. Redistributions of source code must retain the above copyright+   notice, this list of conditions and the following disclaimer. -    * Redistributions in binary form must reproduce the above-      copyright notice, this list of conditions and the following-      disclaimer in the documentation and/or other materials provided-      with the distribution.+2. Redistributions in binary form must reproduce the above copyright+   notice, this list of conditions and the following disclaimer in the+   documentation and/or other materials provided with the distribution. -    * Neither the name of Thomas M. DuBuisson nor the names of other-      contributors may be used to endorse or promote products derived-      from this software without specific prior written permission.+3. Neither the name of the author nor the names of his contributors+   may be used to endorse or promote products derived from this software+   without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT-OWNER OR CONTRIBUTORS 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.+THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS+OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS 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.
Setup.hs view
@@ -1,2 +1,49 @@ import Distribution.Simple-main = defaultMain+import Distribution.Simple.LocalBuildInfo+import Distribution.Simple.Setup+import Distribution.PackageDescription+import Distribution.Simple.Utils+import Distribution.Simple.Program+import Distribution.Verbosity+import System.Process+import System.Directory+import System.FilePath+import System.Exit++main = defaultMainWithHooks hk+ where+ hk = simpleUserHooks { buildHook = \pd lbi uh bf -> do+                                        -- let ccProg = Program "gcc" undefined undefined undefined+                                        let hcProg = Program "ghc" undefined undefined undefined+                                            mConf  = lookupProgram hcProg (withPrograms lbi)+                                            err    = error "Could not determine C compiler"+                                            cc     = locationPath . programLocation  . maybe err id $ mConf+                                        b <- canUseRDRAND cc+                                        let newWithPrograms1 = userSpecifyArgs "gcc" cArgs (withPrograms lbi)+                                            newWithPrograms  = userSpecifyArgs "ghc" cArgsHC newWithPrograms1+                                            lbiNew = if b then (lbi {withPrograms = newWithPrograms }) else lbi+                                        buildHook simpleUserHooks pd lbiNew uh bf+                      }++cArgs :: [String]+cArgs = ["-DHAVE_RDRAND"]++cArgsHC :: [String]+cArgsHC = map ("-optc" ++) cArgs++canUseRDRAND :: FilePath -> IO Bool+canUseRDRAND cc = do+        withTempDirectory normal "" "testRDRAND" $ \tmpDir -> do+        writeFile (tmpDir ++ "/testRDRAND.c")+                (unlines        [ "#include <stdint.h>"+                                , "int main() {"+                                , "   uint64_t therand;"+                                , "   unsigned char err;"+                                , "   asm volatile(\"rdrand %0 ; setc %1\""+                                , "     : \"=r\" (therand), \"=qm\" (err));"+                                , "   return (!err);"+                                , "}"+                                ])+        ec <- rawSystemExitCode normal cc [tmpDir </> "testRDRAND.c", "-o", tmpDir ++ "/a.o","-c"]+        notice normal $ "Result of RDRAND Test: " ++ show (ec == ExitSuccess)+        return (ec == ExitSuccess)
System/Entropy.hs view
@@ -19,7 +19,6 @@ import Control.Monad (liftM) import Data.ByteString as B import System.IO.Error (mkIOError, eofErrorType, ioeSetErrorString)-import System.Posix (openFd, closeFd, fdReadBuf, OpenMode(..), defaultFileFlags, Fd) import Foreign (allocaBytes)  #if defined(isWindows)@@ -150,6 +149,7 @@  #else {- Not windows, assuming nix with a /dev/urandom -}+import System.Posix (openFd, closeFd, fdReadBuf, OpenMode(..), defaultFileFlags, Fd) import Foreign.Ptr  source :: FilePath
entropy.cabal view
@@ -1,5 +1,5 @@ name:           entropy-version:        0.2.2.3+version:        0.2.2.4 description:    A platform independent method to obtain cryptographically strong entropy                  (urandom on Linux, CryptAPI on Windows, patches welcome).                  Users looking for cryptographically strong (number-theoretically