Rewrite against a newer cryptonum.
This commit is contained in:
5
tests/rsa/CHANGELOG.md
Normal file
5
tests/rsa/CHANGELOG.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Revision history for genrsa
|
||||
|
||||
## 0.1.0.0 -- YYYY-mm-dd
|
||||
|
||||
* First version. Released on an unsuspecting world.
|
||||
13
tests/rsa/LICENSE
Normal file
13
tests/rsa/LICENSE
Normal file
@@ -0,0 +1,13 @@
|
||||
Copyright (c) 2018 Adam Wick
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose
|
||||
with or without fee is hereby granted, provided that the above copyright notice
|
||||
and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
THIS SOFTWARE.
|
||||
2
tests/rsa/Setup.hs
Normal file
2
tests/rsa/Setup.hs
Normal file
@@ -0,0 +1,2 @@
|
||||
import Distribution.Simple
|
||||
main = defaultMain
|
||||
21
tests/rsa/genrsa.cabal
Normal file
21
tests/rsa/genrsa.cabal
Normal file
@@ -0,0 +1,21 @@
|
||||
name: genrsa
|
||||
version: 0.1.0.0
|
||||
-- synopsis:
|
||||
-- description:
|
||||
license: ISC
|
||||
license-file: LICENSE
|
||||
author: Adam Wick
|
||||
maintainer: awick@uhsure.com
|
||||
-- copyright:
|
||||
category: Math
|
||||
build-type: Simple
|
||||
extra-source-files: CHANGELOG.md
|
||||
cabal-version: >=1.10
|
||||
|
||||
executable genrsa
|
||||
main-is: genrsa.hs
|
||||
-- other-modules:
|
||||
-- other-extensions:
|
||||
build-depends: base >=4.11 && <4.12, RSA >=2.3 && <2.4, crypto-api >=0.13 && <0.14, bytestring >=0.10 && <0.11, containers >=0.5 && <0.6
|
||||
-- hs-source-dirs:
|
||||
default-language: Haskell2010
|
||||
@@ -63,6 +63,8 @@ genCase g0 size =
|
||||
(Right sig, Right (cipher, g4)) ->
|
||||
(Map.fromList [("d", Numeric.showHex d ""),
|
||||
("n", Numeric.showHex n ""),
|
||||
("k", Numeric.showHex (computeK n) ""),
|
||||
("u", Numeric.showHex (barrett n) "" ),
|
||||
("h", show hashlen),
|
||||
("m", showBytes msg),
|
||||
("s", showBytes sig),
|
||||
@@ -72,6 +74,20 @@ genCase g0 size =
|
||||
(_, _) ->
|
||||
genCase g3 size
|
||||
|
||||
base :: Integer
|
||||
base = 2 ^ (64 :: Integer)
|
||||
|
||||
barrett :: Integer -> Integer
|
||||
barrett m = (base ^ (2 * k)) `div` m
|
||||
where
|
||||
k = computeK m
|
||||
|
||||
computeK :: Integer -> Int
|
||||
computeK v = go 0 1
|
||||
where
|
||||
go k acc | v <= acc = k
|
||||
| otherwise = go (k + 1) (acc * base)
|
||||
|
||||
go :: CryptoRandomGen g => g -> Handle -> Int -> Int -> IO ()
|
||||
go _ _ _ 0 = return ()
|
||||
go g hndl size count =
|
||||
10500
tests/rsa/rsa1024.test
10500
tests/rsa/rsa1024.test
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
10500
tests/rsa/rsa2048.test
10500
tests/rsa/rsa2048.test
File diff suppressed because it is too large
Load Diff
10500
tests/rsa/rsa3072.test
10500
tests/rsa/rsa3072.test
File diff suppressed because it is too large
Load Diff
10500
tests/rsa/rsa4096.test
10500
tests/rsa/rsa4096.test
File diff suppressed because it is too large
Load Diff
10500
tests/rsa/rsa512.test
10500
tests/rsa/rsa512.test
File diff suppressed because one or more lines are too long
10500
tests/rsa/rsa8192.test
10500
tests/rsa/rsa8192.test
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user