package gapi-ocaml

  1. Overview
  2. Docs
A simple OCaml client for Google Services

Install

Dune Dependency

Authors

Maintainers

Sources

v0.4.6.tar.gz
sha256=b84b680528a5e050014103a8e7a60a5d43efd5fefc3f838310bd46769775ab48
md5=8ee26acf1f6c6f5e24c7b57fa070a0a2

doc/src/gapi-ocaml.netsys-local/netsys_crypto_types.ml.html

Source file netsys_crypto_types.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
(* $Id$ *)

module type TLS_EXCEPTIONS =
  sig
    exception EAGAIN_RD
    exception EAGAIN_WR
    exception TLS_switch_request
    exception TLS_switch_response of bool
    exception TLS_error of string
    exception TLS_warning of string
  end

module type TLS_PROVIDER =
  sig
    type config
    type credentials
    type endpoint

    module Exc : TLS_EXCEPTIONS

    val error_message : string -> string

    type dh_params =
        [ `PKCS3_PEM_file of string
        | `PKCS3_DER of string
        | `Generate of int
        ]

    val create_config :
          ?algorithms : string ->
          ?dh_params : dh_params ->
          ?verify : (endpoint -> bool -> bool -> bool) ->
          peer_auth : [ `None | `Optional | `Required ] ->
          credentials : credentials ->
          unit ->
            config

    type crt_list =
        [`PEM_file of string | `DER of string list]
    type crl_list =
        [`PEM_file of string | `DER of string list]
    type private_key =
        [ `PEM_file of string 
        | `RSA of string 
        | `DSA of string
        | `EC of string
        | `PKCS8 of string
        | `PKCS8_encrypted of string
        ]
    val create_x509_credentials :
          ?system_trust:bool ->
          ?trust : crt_list list ->
          ?revoke : crl_list list ->
          ?keys : (crt_list * private_key * string option) list ->
          unit ->
            credentials

    val create_endpoint :
          role : [ `Server | `Client ] ->
          recv : (Netsys_types.memory -> int) ->
          send : (Netsys_types.memory -> int -> int) ->
          peer_name : string option ->
          config ->
            endpoint
    val stash_endpoint : endpoint -> exn
    val restore_endpoint : 
          recv : (Netsys_types.memory -> int) ->
          send : (Netsys_types.memory -> int -> int) ->
          exn ->
            endpoint
    val resume_client :
          recv : (Netsys_types.memory -> int) ->
          send : (Netsys_types.memory -> int -> int) ->
          peer_name : string option ->
          config ->
          string ->
            endpoint

    type state =
        [ `Start | `Handshake | `Data_rw | `Data_r | `Data_w | `Data_rs
        | `Switching | `Accepting | `Refusing | `End
        ]

    val get_state : endpoint -> state

    type raw_credentials =
      [ `X509 of string
      | `Anonymous
      ]

    val at_transport_eof : endpoint -> bool
    val hello : endpoint -> unit
    val bye : endpoint -> Unix.shutdown_command -> unit
    val verify : endpoint -> unit
    val get_config : endpoint -> config
    val get_endpoint_creds : endpoint -> raw_credentials
    val get_peer_creds : endpoint -> raw_credentials
    val get_peer_creds_list : endpoint -> raw_credentials list
    val switch : endpoint -> config -> unit
    val accept_switch : endpoint -> config -> unit
    val refuse_switch : endpoint -> unit
    val send : endpoint -> Netsys_types.memory -> int -> int
    val recv : endpoint -> Netsys_types.memory -> int
    val recv_will_not_block : endpoint -> bool
    val get_session_id : endpoint -> string
    val get_session_data : endpoint -> string
    val get_cipher_suite_type : endpoint -> string
    val get_cipher_algo : endpoint -> string
    val get_kx_algo : endpoint -> string
    val get_mac_algo : endpoint -> string
    val get_compression_algo : endpoint -> string
    val get_cert_type : endpoint -> string
    val get_protocol : endpoint -> string

    type server_name = [ `Domain of string ]

    val get_addressed_servers : endpoint -> server_name list
    val set_session_cache : store:(string -> string -> unit) ->
                            remove:(string -> unit) ->
                            retrieve:(string -> string) ->
                            endpoint ->
                            unit
    val implementation_name : string
    val implementation : unit -> exn
  end


module type TLS_CONFIG =
  sig
    module TLS : TLS_PROVIDER
    val config : TLS.config
  end


module type TLS_ENDPOINT =
  sig
    module TLS : TLS_PROVIDER
    val endpoint : TLS.endpoint
  end


module type FILE_TLS_ENDPOINT =
  sig
    module TLS : TLS_PROVIDER
    val endpoint : TLS.endpoint
    val rd_file : Unix.file_descr
    val wr_file : Unix.file_descr
  end

module type SYMMETRIC_CRYPTO = sig
  type scipher
  val ciphers : scipher list
  val find : (string * string) -> scipher
  val name : scipher -> string
  val mode : scipher -> string
  val key_lengths : scipher -> (int * int) list
  val iv_lengths : scipher -> (int * int) list
  val block_constraint : scipher -> int
  val supports_aead : scipher -> bool
  type scipher_ctx
  val create : scipher -> string -> scipher_ctx
  val set_iv : scipher_ctx -> string -> unit
  val set_header : scipher_ctx -> string -> unit
  val encrypt : scipher_ctx -> 
                Netsys_types.memory ->
                Netsys_types.memory ->
                  unit
  val decrypt : scipher_ctx -> 
                Netsys_types.memory ->
                Netsys_types.memory ->
                  bool
  val mac : scipher_ctx -> string
end


module type DIGESTS = sig
    type digest
    val digests : digest list
    val find : string -> digest
    val name : digest -> string
    val size : digest -> int
    val block_length : digest -> int
    type digest_ctx
    val create : digest -> digest_ctx
    val add : digest_ctx -> Netsys_types.memory -> unit
    val finish : digest_ctx -> string
end

module type PUBKEY_CRYPTO = sig
    type public_key
    type private_key
    type pin_callback
    type algorithm

    val supported_x509 : int array list
    val algorithm_x509 : int array -> string option -> algorithm
    val import_public_key_x509 : string -> public_key
    val import_public_key_uri : string -> public_key
    val import_public_key_uri_with_pin : pin_callback -> string -> public_key

    type x509_private_key = string * string

    val import_private_key_x509 : x509_private_key -> private_key

    val import_private_key_uri : string -> private_key
    val import_private_key_uri_with_pin : pin_callback -> string -> private_key

    val import_public_key_from_private : private_key -> public_key

    val simple_pin_callback : (unit -> string) -> pin_callback

    val encrypt : algorithm -> public_key -> string -> string
    val decrypt : algorithm -> private_key -> string -> string
    val verify : algorithm -> public_key -> string -> string -> bool
    val sign : algorithm -> private_key -> string -> string
end

type tls_provider = (module TLS_PROVIDER)
type tls_config = (module TLS_CONFIG)
type tls_endpoint = (module TLS_ENDPOINT)
type file_tls_endpoint = (module FILE_TLS_ENDPOINT)
type symmetric_crypto = (module SYMMETRIC_CRYPTO)
type digests = (module DIGESTS)
type pubkey_crypto = (module PUBKEY_CRYPTO)
OCaml

Innovation. Community. Security.