packages feed

nist-beacon (empty) → 0.1.0.0

raw patch · 21 files changed

+566/−0 lines, 21 filesdep +HTTPdep +basedep +bytestringsetup-changedbinary-added

Dependencies added: HTTP, base, bytestring, xml

Files

+ .gitignore view
@@ -0,0 +1,17 @@+dist+cabal-dev+*.o+*.hi+*.chi+*.chs.h+*.dyn_o+*.dyn_hi+.virtualenv+.hpc+.hsenv+.cabal-sandbox/+.stack-work/+cabal.sandbox.config+*.prof+*.aux+*.hp
+ .gitignore~ view
@@ -0,0 +1,16 @@+dist+cabal-dev+*.o+*.hi+*.chi+*.chs.h+*.dyn_o+*.dyn_hi+.virtualenv+.hpc+.hsenv+.cabal-sandbox/+cabal.sandbox.config+*.prof+*.aux+*.hp
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2015, Bryan St. Amour++All rights reserved.++Redistribution and use in source and binary forms, with or without+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.++    * 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 Bryan St. Amour nor the names of other+      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.
+ LICENSE.save0 view
@@ -0,0 +1,28 @@+Copyright (c) 2015, Bryan St. Amour+All rights reserved.++Redistribution and use in source and binary forms, with or without+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.++* 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 haskell-nist-beacon nor the names of its+  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 HOLDER 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.+
+ README.md view
@@ -0,0 +1,2 @@+# haskell-nist-beacon+Simple interface to the NIST Randomness Beacon.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ cabal.sandbox.config view
@@ -0,0 +1,25 @@+-- This is a Cabal package environment file.+-- THIS FILE IS AUTO-GENERATED. DO NOT EDIT DIRECTLY.+-- Please create a 'cabal.config' file in the same directory+-- if you want to change the default settings for this sandbox.+++local-repo: /home/bryan/Projects/haskell-nist-beacon/.cabal-sandbox/packages+logs-dir: /home/bryan/Projects/haskell-nist-beacon/.cabal-sandbox/logs+world-file: /home/bryan/Projects/haskell-nist-beacon/.cabal-sandbox/world+user-install: False+package-db: /home/bryan/Projects/haskell-nist-beacon/.cabal-sandbox/x86_64-linux-ghc-7.10.1-packages.conf.d+build-summary: /home/bryan/Projects/haskell-nist-beacon/.cabal-sandbox/logs/build.log++install-dirs+  prefix: /home/bryan/Projects/haskell-nist-beacon/.cabal-sandbox+  bindir: $prefix/bin+  libdir: $prefix/lib+  libsubdir: $abi/$pkgkey+  libexecdir: $prefix/libexec+  datadir: $prefix/share+  datasubdir: $abi/$pkgid+  docdir: $datadir/doc/$abi/$pkgid+  htmldir: $docdir/html+  haddockdir: $htmldir+  sysconfdir: $prefix/etc
+ dist/build/Net/Beacon.dyn_hi view

binary file changed (absent → 13176 bytes)

+ dist/build/Net/Beacon.dyn_o view

binary file changed (absent → 56680 bytes)

+ dist/build/Net/Beacon.hi view

binary file changed (absent → 13164 bytes)

+ dist/build/Net/Beacon.o view

binary file changed (absent → 58624 bytes)

+ dist/build/autogen/Paths_nist_beacon.hs view
@@ -0,0 +1,35 @@+module Paths_nist_beacon (+    version,+    getBinDir, getLibDir, getDataDir, getLibexecDir,+    getDataFileName, getSysconfDir+  ) where++import qualified Control.Exception as Exception+import Data.Version (Version(..))+import System.Environment (getEnv)+import Prelude++catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a+catchIO = Exception.catch++version :: Version+version = Version [0,1,0,0] []+bindir, libdir, datadir, libexecdir, sysconfdir :: FilePath++bindir     = "/home/bryan/Projects/haskell-nist-beacon/.cabal-sandbox/bin"+libdir     = "/home/bryan/Projects/haskell-nist-beacon/.cabal-sandbox/lib/x86_64-linux-ghc-7.10.1/nistb_5LnrD4LS2EC3KQmdUu0sUM"+datadir    = "/home/bryan/Projects/haskell-nist-beacon/.cabal-sandbox/share/x86_64-linux-ghc-7.10.1/nist-beacon-0.1.0.0"+libexecdir = "/home/bryan/Projects/haskell-nist-beacon/.cabal-sandbox/libexec"+sysconfdir = "/home/bryan/Projects/haskell-nist-beacon/.cabal-sandbox/etc"++getBinDir, getLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath+getBinDir = catchIO (getEnv "nist_beacon_bindir") (\_ -> return bindir)+getLibDir = catchIO (getEnv "nist_beacon_libdir") (\_ -> return libdir)+getDataDir = catchIO (getEnv "nist_beacon_datadir") (\_ -> return datadir)+getLibexecDir = catchIO (getEnv "nist_beacon_libexecdir") (\_ -> return libexecdir)+getSysconfDir = catchIO (getEnv "nist_beacon_sysconfdir") (\_ -> return sysconfdir)++getDataFileName :: FilePath -> IO FilePath+getDataFileName name = do+  dir <- getDataDir+  return (dir ++ "/" ++ name)
+ dist/build/autogen/cabal_macros.h view
@@ -0,0 +1,123 @@+/* DO NOT EDIT: This file is automatically generated by Cabal */++/* package HTTP-4000.2.19 */+#define VERSION_HTTP "4000.2.19"+#define MIN_VERSION_HTTP(major1,major2,minor) (\+  (major1) <  4000 || \+  (major1) == 4000 && (major2) <  2 || \+  (major1) == 4000 && (major2) == 2 && (minor) <= 19)++/* package base-4.8.0.0 */+#define VERSION_base "4.8.0.0"+#define MIN_VERSION_base(major1,major2,minor) (\+  (major1) <  4 || \+  (major1) == 4 && (major2) <  8 || \+  (major1) == 4 && (major2) == 8 && (minor) <= 0)++/* package bytestring-0.10.6.0 */+#define VERSION_bytestring "0.10.6.0"+#define MIN_VERSION_bytestring(major1,major2,minor) (\+  (major1) <  0 || \+  (major1) == 0 && (major2) <  10 || \+  (major1) == 0 && (major2) == 10 && (minor) <= 6)++/* package xml-1.3.14 */+#define VERSION_xml "1.3.14"+#define MIN_VERSION_xml(major1,major2,minor) (\+  (major1) <  1 || \+  (major1) == 1 && (major2) <  3 || \+  (major1) == 1 && (major2) == 3 && (minor) <= 14)++/* tool alex-3.1.4 */+#define TOOL_VERSION_alex "3.1.4"+#define MIN_TOOL_VERSION_alex(major1,major2,minor) (\+  (major1) <  3 || \+  (major1) == 3 && (major2) <  1 || \+  (major1) == 3 && (major2) == 1 && (minor) <= 4)++/* tool c2hs-0.25.2 */+#define TOOL_VERSION_c2hs "0.25.2"+#define MIN_TOOL_VERSION_c2hs(major1,major2,minor) (\+  (major1) <  0 || \+  (major1) == 0 && (major2) <  25 || \+  (major1) == 0 && (major2) == 25 && (minor) <= 2)++/* tool cpphs-1.19 */+#define TOOL_VERSION_cpphs "1.19"+#define MIN_TOOL_VERSION_cpphs(major1,major2,minor) (\+  (major1) <  1 || \+  (major1) == 1 && (major2) <  19 || \+  (major1) == 1 && (major2) == 19 && (minor) <= 0)++/* tool gcc-4.9.2 */+#define TOOL_VERSION_gcc "4.9.2"+#define MIN_TOOL_VERSION_gcc(major1,major2,minor) (\+  (major1) <  4 || \+  (major1) == 4 && (major2) <  9 || \+  (major1) == 4 && (major2) == 9 && (minor) <= 2)++/* tool ghc-7.10.1 */+#define TOOL_VERSION_ghc "7.10.1"+#define MIN_TOOL_VERSION_ghc(major1,major2,minor) (\+  (major1) <  7 || \+  (major1) == 7 && (major2) <  10 || \+  (major1) == 7 && (major2) == 10 && (minor) <= 1)++/* tool ghc-pkg-7.10.1 */+#define TOOL_VERSION_ghc_pkg "7.10.1"+#define MIN_TOOL_VERSION_ghc_pkg(major1,major2,minor) (\+  (major1) <  7 || \+  (major1) == 7 && (major2) <  10 || \+  (major1) == 7 && (major2) == 10 && (minor) <= 1)++/* tool haddock-2.16.0 */+#define TOOL_VERSION_haddock "2.16.0"+#define MIN_TOOL_VERSION_haddock(major1,major2,minor) (\+  (major1) <  2 || \+  (major1) == 2 && (major2) <  16 || \+  (major1) == 2 && (major2) == 16 && (minor) <= 0)++/* tool happy-1.19.5 */+#define TOOL_VERSION_happy "1.19.5"+#define MIN_TOOL_VERSION_happy(major1,major2,minor) (\+  (major1) <  1 || \+  (major1) == 1 && (major2) <  19 || \+  (major1) == 1 && (major2) == 19 && (minor) <= 5)++/* tool hpc-0.67 */+#define TOOL_VERSION_hpc "0.67"+#define MIN_TOOL_VERSION_hpc(major1,major2,minor) (\+  (major1) <  0 || \+  (major1) == 0 && (major2) <  67 || \+  (major1) == 0 && (major2) == 67 && (minor) <= 0)++/* tool hsc2hs-0.67 */+#define TOOL_VERSION_hsc2hs "0.67"+#define MIN_TOOL_VERSION_hsc2hs(major1,major2,minor) (\+  (major1) <  0 || \+  (major1) == 0 && (major2) <  67 || \+  (major1) == 0 && (major2) == 67 && (minor) <= 0)++/* tool hscolour-1.22 */+#define TOOL_VERSION_hscolour "1.22"+#define MIN_TOOL_VERSION_hscolour(major1,major2,minor) (\+  (major1) <  1 || \+  (major1) == 1 && (major2) <  22 || \+  (major1) == 1 && (major2) == 22 && (minor) <= 0)++/* tool pkg-config-0.28 */+#define TOOL_VERSION_pkg_config "0.28"+#define MIN_TOOL_VERSION_pkg_config(major1,major2,minor) (\+  (major1) <  0 || \+  (major1) == 0 && (major2) <  28 || \+  (major1) == 0 && (major2) == 28 && (minor) <= 0)++/* tool strip-2.24 */+#define TOOL_VERSION_strip "2.24"+#define MIN_TOOL_VERSION_strip(major1,major2,minor) (\+  (major1) <  2 || \+  (major1) == 2 && (major2) <  24 || \+  (major1) == 2 && (major2) == 24 && (minor) <= 0)++#define CURRENT_PACKAGE_KEY "nistb_5LnrD4LS2EC3KQmdUu0sUM"+
+ dist/build/libHSnist-beacon-0.1.0.0-5LnrD4LS2EC3KQmdUu0sUM-ghc7.10.1.so view

binary file changed (absent → 68610 bytes)

+ dist/build/libHSnist-beacon-0.1.0.0-5LnrD4LS2EC3KQmdUu0sUM.a view

binary file changed (absent → 55862 bytes)

+ dist/package.conf.inplace/package.cache view

binary file changed (absent → 40 bytes)

+ dist/setup-config view

binary file changed (absent → 151873 bytes)

+ nist-beacon.cabal view
@@ -0,0 +1,67 @@+-- Initial nist-beacon.cabal generated by cabal init.  For further +-- documentation, see http://haskell.org/cabal/users-guide/++-- The name of the package.+name:                nist-beacon++-- The package version.  See the Haskell package versioning policy (PVP) +-- for standards guiding when and how versions should be incremented.+-- http://www.haskell.org/haskellwiki/Package_versioning_policy+-- PVP summary:      +-+------- breaking API changes+--                   | | +----- non-breaking API additions+--                   | | | +--- code changes with no API change+version:             0.1.0.0++-- A short (one-line) description of the package.+synopsis: Haskell interface to the nist random beacon.           ++-- A longer description of the package.+-- description:         ++-- The license under which the package is released.+license:             BSD3++-- The file containing the license text.+license-file:        LICENSE++-- The package author(s).+author:              Bryan St. Amour++-- An email address to which users can send suggestions, bug reports, and +-- patches.+maintainer:          bryan@bryanstamour.com++-- A copyright notice.+-- copyright:           ++category:            Network++build-type:          Simple++-- Extra files to be distributed with the package, such as examples or a +-- README.+extra-source-files:  README.md++-- Constraint on the version of Cabal needed to build this package.+cabal-version:       >=1.10+++library+  -- Modules exported by the library.+  exposed-modules:     Net.Beacon+  +  -- Modules included in this library but not exported.+  -- other-modules:       +  +  -- LANGUAGE extensions used by modules in this package.+  -- other-extensions:    +  +  -- Other library packages from which modules are imported.+  build-depends:       base >=4.8 && <4.9, xml >=1.3 && <1.4, HTTP >=4000.2 && <4000.3, bytestring >=0.10 && <0.11+  +  -- Directories containing source files.+  hs-source-dirs:      src+  +  -- Base language which the package is written in.+  default-language:    Haskell2010+  
+ nist-beacon.cabal~ view
@@ -0,0 +1,67 @@+-- Initial nist-beacon.cabal generated by cabal init.  For further +-- documentation, see http://haskell.org/cabal/users-guide/++-- The name of the package.+name:                nist-beacon++-- The package version.  See the Haskell package versioning policy (PVP) +-- for standards guiding when and how versions should be incremented.+-- http://www.haskell.org/haskellwiki/Package_versioning_policy+-- PVP summary:      +-+------- breaking API changes+--                   | | +----- non-breaking API additions+--                   | | | +--- code changes with no API change+version:             0.1.0.0++-- A short (one-line) description of the package.+synopsis: Haskell interface to the nist random beacon.           ++-- A longer description of the package.+-- description:         ++-- The license under which the package is released.+license:             BSD3++-- The file containing the license text.+license-file:        LICENSE++-- The package author(s).+author:              Bryan St. Amour++-- An email address to which users can send suggestions, bug reports, and +-- patches.+maintainer:          bryan@bryanstamour.com++-- A copyright notice.+-- copyright:           ++category:            Network++build-type:          Simple++-- Extra files to be distributed with the package, such as examples or a +-- README.+extra-source-files:  README.md++-- Constraint on the version of Cabal needed to build this package.+cabal-version:       >=1.10+++library+  -- Modules exported by the library.+  exposed-modules:     Net.Beacon+  +  -- Modules included in this library but not exported.+  -- other-modules:       +  +  -- LANGUAGE extensions used by modules in this package.+  -- other-extensions:    +  +  -- Other library packages from which modules are imported.+  build-depends:       base >=4.8 && <4.9, xml >=1.3 && <1.4, HTTP >=4000.2 && <4000.3, bytestring >=0.10 && <0.11+  +  -- Directories containing source files.+  hs-source-dirs:      src+  +  -- Base language which the package is written in.+  default-language:    Haskell2010+  
+ src/Net/Beacon.hs view
@@ -0,0 +1,149 @@+{-|+Module      : Beacon+Description : Module for interacting with the NIST Randomness Beacon.+Copyright   : (c) Bryan St. Amour, 2015+License     : BSD+Maintainer  : bryan@bryanstamour.com+Stability   : experimental+Portability : POSIX++This module is for interacting with the NIST Randomness Beacon (prototype)+web API. The Randomness Beacon is designed to be a public source of random+information. It generates and publishes 512-bit blocks of random data collected+from a quantum mechanical process every 60 seconds.++For more information about the project, see++    https://beacon.nist.gov/home+-}+++module Net.Beacon+       ( Timestamp+       , Record()+       , version+       , frequency+       , timeStamp+       , seedValue+       , previousOutputValue+       , signatureValue+       , outputValue+       , statusCode+       , getLastRecord+       , getCurrentRecord+       , getPreviousRecord+       , getNextRecord+       , getStartChainRecord+       ) where+++import Control.Monad++import Text.XML.Light.Input+import Text.XML.Light.Proc+import Text.XML.Light.Types++import Network.HTTP (getResponseBody, simpleHTTP, getRequest)++import qualified Data.ByteString.Lazy.Char8 as B+++-- | A single record: the random data plus some additional information.+data Record =+  Record+  { -- | A simple version string, e.g. "0.1.0".+    version :: String++    -- | The time interval, in seconds, between expected records.+  , frequency :: Int++    -- | The time the seed value was generated as the number of seconds since+    --   January 1, 1970.+  , timeStamp :: Int++    -- | A seed value represented as a 64 byte (512-bit) hex string value.+  , seedValue :: B.ByteString++    -- | The SHA-512 hash value for the previous record - 64 byte hex string.+  , previousOutputValue :: B.ByteString++    -- | A digital signature (RSA) computed over (in order):+    --   version, frequency, timeStamp, seedValue, previousHashValue,+    --   errorCode.+    --+    --   Note: Except for version, the hash is on the byte representations+    --   and not the string representations of the data values.+  , signatureValue :: B.ByteString++    -- | The SHA-512 hash of the signatureValue as a 64 byte hex string.+  , outputValue :: B.ByteString++    -- | The status code value:+    --     0 - Chain intact, values all good+    --     1 - Start of a new chain of values, previous hash value will be all+    --         zeroes+    --     2 - Time between values is greater than the frequency, but the+    --         chain is still intact+  , statusCode :: Int+  } deriving (Show, Eq)+++type Timestamp = Int+++-- | Last record published.+getLastRecord :: IO (Maybe Record)+getLastRecord = do+  x <- getXmlData "http://beacon.nist.gov/rest/record/last"+  return $ getRecord x+++-- | Current record, or closest to the timestamp.+getCurrentRecord :: Timestamp -> IO (Maybe Record)+getCurrentRecord ts = do+  x <- getXmlData $ "http://beacon.nist.gov/rest/record/" ++ (show ts)+  return $ getRecord x+++-- | Previous record.+getPreviousRecord :: Timestamp -> IO (Maybe Record)+getPreviousRecord ts = do+  x <- getXmlData $ "http://beacon.nist.gov/rest/record/previous/" ++ (show ts)+  return $ getRecord x+++-- | Next record.+getNextRecord :: Timestamp -> IO (Maybe Record)+getNextRecord ts = do+  x <- getXmlData $ "http://beacon.nist.gov/rest/record/next/" ++ (show ts)+  return $ getRecord x+++-- | Start chain record.+getStartChainRecord :: Timestamp -> IO (Maybe Record)+getStartChainRecord ts = do+  x <- getXmlData $ "http://beacon.nist.gov/rest/record/start-chain/" ++ (show ts)+  return $ getRecord x+++getXmlData :: String -> IO B.ByteString+getXmlData url = do+  body <- getResponseBody <=< simpleHTTP $ getRequest url+  return $ B.pack body+++getRecord :: B.ByteString -> Maybe Record+getRecord stuff = do+  xml <- parseXMLDoc stuff+  let fc = findChild' xml+  Record+    <$>             fc "version"+    <*> (read   <$> fc "frequency")+    <*> (read   <$> fc "timeStamp")+    <*> (B.pack <$> fc "seedValue")+    <*> (B.pack <$> fc "previousOutputValue")+    <*> (B.pack <$> fc "signatureValue")+    <*> (B.pack <$> fc "outputValue")+    <*> (read   <$> fc "statusCode")+  where+    findChild' xml name = strContent <$> findChild (QName name Nothing Nothing) xml
+ stack.yaml view
@@ -0,0 +1,5 @@+flags: {}+packages:+- '.'+extra-deps: []+resolver: lts-3.4