Skip to content
Newer
Older
100644 110 lines (97 sloc) 3.3 KB
d8a6a59 @phonohawk Initial import
authored
1 {- -*- haskell -*- -}
df27224 @phonohawk Implemented OpenSSL.EVP.Base64 / Buried OpenSSL.BIO
authored
2
3 -- |HsOpenSSL is a (part of) OpenSSL binding for Haskell. It can
4 -- generate RSA keys, read and write PEM files, generate message
5 -- digests, sign and verify messages, encrypt and decrypt messages.
6 -- But since OpenSSL is a very large library, it is uneasy to cover
7 -- everything in it.
8 --
9 -- Features that aren't (yet) supported:
10 --
11 -- [/TLS\/SSL network connection/] ssl(3) functionalities are
12 -- totally uncovered. They should be covered someday.
13 --
14 -- [/Low-level API to symmetric ciphers/] Only high-level APIs (EVP
15 -- and BIO) are available. But I believe no one will be lost without
16 -- functions like @DES_set_odd_parity@.
17 --
18 -- [/Low-level API to asymmetric ciphers/] Only a high-level API
19 -- (EVP) is available. But I believe no one will complain about the
20 -- absence of functions like @RSA_public_encrypt@.
21 --
22 -- [/Key generation of DSA and Diffie-Hellman algorithms/] Only RSA
23 -- keys can currently be generated.
24 --
25 -- [/X.509 certificate handling/] No operations related to X.509 are
26 -- currently supported. They should be supported in the future.
27 --
28 -- [/HMAC message authentication/]
29 --
30 -- [/Low-level API to message digest functions/] Just use EVP or BIO
31 -- instead of something like @MD5_Update@.
32 --
33 -- [/pseudo-random number generator/] rand(3) functionalities are
34 -- uncovered, but OpenSSL works very well by default.
35 --
36 -- [/API to ASN.1, PKCS\#7 and PKCS\#12 functionalities/] They
37 -- should be covered someday, but there seems no documents for those
38 -- APIs.
39 --
40 -- [/BIO/] BIO isn't needed because we are Haskell hackers.
41 --
42 -- [/ENGINE cryptographic module/] The default implementations work
43 -- very well, don't they?
44 --
45 -- [/bn(3), buffer(3), lhash(3), objects(3), stack(3) and txt_db(3)/]
46 -- These internal functions are rarely used by application
47 -- programmers.
48 --
49 -- So if you find out some features you want aren't supported, you
50 -- must write your own patch. Happy hacking.
51
52 #include "HsOpenSSL.h"
53
d8a6a59 @phonohawk Initial import
authored
54 module OpenSSL
df27224 @phonohawk Implemented OpenSSL.EVP.Base64 / Buried OpenSSL.BIO
authored
55 ( -- * Initialization
56 withOpenSSL
57
58 -- * High-level cryptographic functions
59 , module OpenSSL.EVP.Cipher
60 , module OpenSSL.EVP.Digest
61 , module OpenSSL.EVP.Open
62 , module OpenSSL.EVP.PKey
63 , module OpenSSL.EVP.Seal
64 , module OpenSSL.EVP.Sign
65 , module OpenSSL.EVP.Verify
66
67 -- * PEM routines
68 , module OpenSSL.PEM
69
70 -- * RSA public key cryptosystem
71 , module OpenSSL.RSA
d8a6a59 @phonohawk Initial import
authored
72 )
73 where
74
df27224 @phonohawk Implemented OpenSSL.EVP.Base64 / Buried OpenSSL.BIO
authored
75
76 import OpenSSL.EVP.Cipher hiding (EVP_CIPHER, EVP_CIPHER_CTX, newCtx, cryptoModeToInt)
77 import OpenSSL.EVP.Digest hiding (EVP_MD, newCtx, EVP_MD_CTX)
78 import OpenSSL.EVP.Open
79 import OpenSSL.EVP.PKey hiding (EVP_PKEY, wrapPKey, pkeySize)
80 import OpenSSL.EVP.Seal
81 import OpenSSL.EVP.Sign
82 import OpenSSL.EVP.Verify
83 import OpenSSL.PEM
84 import OpenSSL.RSA hiding (RSA_)
d8a6a59 @phonohawk Initial import
authored
85 import OpenSSL.SSL
86
df27224 @phonohawk Implemented OpenSSL.EVP.Base64 / Buried OpenSSL.BIO
authored
87
88 foreign import ccall "HsOpenSSL_setupMutex"
89 setupMutex :: IO ()
90
91
92 -- |Computation of @'withOpenSSL' action@ initializes the OpenSSL
93 -- library and computes @action@. Every applications that use OpenSSL
94 -- must wrap any other operations related to OpenSSL or they will
95 -- crash.
96 --
97 -- > module Main where
98 -- > import OpenSSL
99 -- >
100 -- > main :: IO ()
101 -- > main = withOpenSSL $
102 -- > do ...
103 --
d8a6a59 @phonohawk Initial import
authored
104 withOpenSSL :: IO a -> IO a
105 withOpenSSL act
106 = do loadErrorStrings
014bbd0 @phonohawk RSA keys can now be written to an BIO.
authored
107 addAllAlgorithms
df27224 @phonohawk Implemented OpenSSL.EVP.Base64 / Buried OpenSSL.BIO
authored
108 setupMutex
d8a6a59 @phonohawk Initial import
authored
109 act
Something went wrong with that request. Please try again.