aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public_key/doc/src/public_key.xml
blob: 4044c899671af053f79be6396e67f597ed29ae6c (plain) (blame)
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">

<erlref>
  <header>
    <copyright>
      <year>2008</year>
      <year>2013</year>
      <holder>Ericsson AB, All Rights Reserved</holder>
    </copyright>
    <legalnotice>
  The contents of this file are subject to the Erlang Public License,
  Version 1.1, (the "License"); you may not use this file except in
  compliance with the License. You should have received a copy of the
  Erlang Public License along with this software. If not, it can be
  retrieved online at http://www.erlang.org/.

  Software distributed under the License is distributed on an "AS IS"
  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
  the License for the specific language governing rights and limitations
  under the License.

  The Initial Developer of the Original Code is Ericsson AB.
    </legalnotice>

    <title>public_key</title>
    <prepared>Ingela Anderton Andin</prepared>
    <responsible></responsible>
    <docno></docno>
    <date></date>
    <rev></rev>
  </header>
  <module>public_key</module>
  <modulesummary> API module for public key infrastructure.</modulesummary>
  <description>
    <p>This module provides functions to handle public key infrastructure. It can
    encode/decode different file formats (PEM, openssh), sign and verify digital signatures and validate
    certificate paths and certificate revocation lists.
    </p>
  </description>

  <section>
    <title>public_key</title>

    <list type="bulleted">
      <item>public_key requires the crypto and asn1 applications, the latter since R16 (hopefully the runtime dependency on asn1 will
      be removed again in the future).</item>

      <item>Supports <url href="http://www.ietf.org/rfc/rfc5280.txt">RFC 5280 </url> -
      Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile </item>
      <item>Supports <url href="http://www.rsa.com/rsalabs/node.asp?id=2125"> PKCS-1 </url> - RSA Cryptography Standard </item>
      <item>Supports <url href="http://csrc.nist.gov/publications/fips/fips186-3/fips_186-3.pdf"> DSS</url>- Digital Signature Standard (DSA - Digital Signature Algorithm)</item>
      <item>Supports <url href="http://www.rsa.com/rsalabs/node.asp?id=2126"> PKCS-3 </url> - Diffie-Hellman Key Agreement Standard </item>
      <item>Supports <url href="http://www.rsa.com/rsalabs/node.asp?id=2127"> PKCS-5</url> - Password-Based Cryptography Standard </item>
      <item>Supports <url href="http://www.rsa.com/rsalabs/node.asp?id=2130"> PKCS-8</url> - Private-Key Information Syntax Standard</item>
      <item>Supports <url href="http://www.rsa.com/rsalabs/node.asp?id=2132"> PKCS-10</url> - Certification Request Syntax Standard</item>
    </list>
  </section>

  <section>
    <title>COMMON DATA TYPES </title> 
    
    <note><p>All records used in this manual 
    <!--     except #policy_tree_node{}  -->
    are generated from ASN.1 specifications
    and are documented in the User's Guide. See <seealso 
    marker="public_key_records">Public key records</seealso> and <seealso 
    marker="cert_records">X.509 Certificate records</seealso>. 
    </p></note>
    
    <p>Use the following include directive to get access to the 
    records and constant macros described here and in the User's Guide.</p>
    
    <code> -include_lib("public_key/include/public_key.hrl"). </code>

    <p><em>Data Types </em></p>
    
    <p><code>oid() - a tuple of integers as generated by the ASN1 compiler.</code></p>

    <p><code>boolean() = true | false</code></p>

    <p><code>string() = [bytes()]</code></p>

    <p><code>der_encoded() = binary()</code></p>
   
    <p><code>pki_asn1_type() = 'Certificate' | 'RSAPrivateKey'| 'RSAPublicKey' |
    'DSAPrivateKey' | 'DSAPublicKey' | 'DHParameter' | 'SubjectPublicKeyInfo' |
    'PrivateKeyInfo' | 'CertificationRequest' | 'ECPrivateKey'|
    'EcpkParameters'</code></p>
    
    <p><code>pem_entry () = {pki_asn1_type(), binary(), %% DER or encrypted DER
          not_encrypted | cipher_info()} </code></p>

    <p><code>cipher_info()  =  {"RC2-CBC | "DES-CBC" | "DES-EDE3-CBC", crypto:rand_bytes(8)} |
    'PBES2-params'} </code></p>
	  
    <p><code>rsa_public_key()  = #'RSAPublicKey'{}</code></p>

    <p><code>rsa_private_key() = #'RSAPrivateKey'{} </code></p>

    <p><code>dsa_public_key() = {integer(),  #'Dss-Parms'{}} </code></p>

    <p><code>dsa_private_key() = #'DSAPrivateKey'{}</code></p>

    <p><code>ec_public_key()  = {#'ECPoint'{}, #'EcpkParameters'{} | {namedCurve, oid()}} </code></p>
    
    <p><code>ec_private_key()  = #'ECPrivateKey'{}</code></p>

    <p><code> public_crypt_options() = [{rsa_pad, rsa_padding()}]. </code></p>

    <p><code> rsa_padding() =  'rsa_pkcs1_padding' | 'rsa_pkcs1_oaep_padding'
    | 'rsa_no_padding'</code></p>
    
    <p><code> rsa_digest_type()  = 'md5' | 'sha' | 'sha224' | 'sha256' | 'sha384' | 'sha512' </code></p>

    <p><code> dss_digest_type()  = 'sha' </code></p>

    <p><code> ecdsa_digest_type()  = 'sha'| 'sha224' | 'sha256' | 'sha384' | 'sha512' </code></p>

    <p><code> crl_reason()  = unspecified | keyCompromise | cACompromise | affiliationChanged | superseded | cessationOfOperation | certificateHold | privilegeWithdrawn |  aACompromise
    </code></p>

    <p><code> ssh_file()  = openssh_public_key | rfc4716_public_key |
    known_hosts | auth_keys </code></p>
    
<!--     <p><code>policy_tree() = [Root, Children]</code></p> -->
    
<!--     <p><code>Root = #policy_tree_node{}</code></p>    -->

<!--     <p><code>Children = [] | policy_tree()</code></p> -->
	
<!--     <p> The policy_tree_node record has the following fields:</p> -->
    
<!--     <taglist> -->
      
<!--       <tag>valid_policy</tag> -->
<!--       <item> Is a single policy OID representing a -->
<!--          valid policy for the path of length x.</item> -->
      
<!--       <tag>qualifier_set</tag> -->
<!--       <item>A set of policy qualifiers associated -->
<!--          with the valid policy in certificate x.</item> -->
      
<!--       <tag>critically_indicator</tag> -->
<!--       <item>The critically_indicator indicates whether the -->
<!--          certificate policy extension in certificate x was marked as -->
<!--          critical. </item> -->
      
<!--       <tag>expected_policy_set</tag> -->
<!--       <item>The expected_policy_set contains one or more policy OIDs -->
<!--          that would satisfy this policy in the certificate x+1. </item>         -->
<!--     </taglist> -->
  </section> 

<funcs>    

  <func>
    <name> compute_key(OthersKey, MyKey)-></name>
    <name> compute_key(OthersKey, MyKey, Params)-></name>
    <fsummary> Compute shared secret</fsummary>
    <type>
      <v>OthersKey = #'ECPoint'{} | binary(), MyKey = #'ECPrivateKey'{} | binary()</v>
      <v>Params =  #'DHParameter'{}</v>
    </type>
  <desc>
    <p> Compute shared secret </p>
  </desc>
  </func>

  <func>
    <name>decrypt_private(CipherText, Key) -> binary()</name>
    <name>decrypt_private(CipherText, Key, Options) -> binary()</name>
    <fsummary>Public key decryption.</fsummary>
    <type>
      <v>CipherText = binary()</v>
      <v>Key = rsa_private_key()</v>
      <v>Options = public_crypt_options()</v>
  </type> 
  <desc> 
    <p>Public key decryption using the private key.</p> 
  </desc> 
  </func>

  <func>
    <name>decrypt_public(CipherText, Key) - > binary()</name>
    <name>decrypt_public(CipherText, Key, Options) - > binary()</name>
    <fsummary></fsummary>
    <type>
      <v>CipherText = binary()</v>
      <v>Key = rsa_public_key()</v>
      <v>Options = public_crypt_options()</v>
  </type> 
  <desc> 
    <p> Public key decryption using the public key.</p> 
  </desc> 
  </func> 

  <func>
    <name>der_decode(Asn1type, Der) -> term()</name>
    <fsummary> Decodes a public key ASN.1 DER encoded entity.</fsummary>
    <type>
      <v>Asn1Type = atom()</v>
      <d> ASN.1 type present in the public_key applications
      asn1 specifications.</d>
      <v>Der = der_encoded()</v>
    </type> 
    <desc> 
      <p> Decodes a public key ASN.1 DER encoded entity.</p>
    </desc> 
  </func>
    
  <func>
    <name>der_encode(Asn1Type, Entity) -> der_encoded()</name>
    <fsummary> Encodes a public key entity with asn1 DER encoding.</fsummary>
    <type>
      <v>Asn1Type = atom()</v>
      <d> Asn1 type present in the public_key applications
	 ASN.1 specifications.</d>
      <v>Entity = term()</v>
      <d>The erlang representation of <c>Asn1Type</c></d>
  </type> 
  <desc> 
    <p> Encodes a public key entity with ASN.1 DER encoding.</p>
  </desc> 
  </func>

  <func>
    <name>generate_key(Params) -> {Public::binary(), Private::binary()}  | #'ECPrivateKey'{} </name>
    <fsummary>Generates a new keypair</fsummary>
    <type>
      <v> Params = #'DHParameter'{} |  {namedCurve, oid()} |  #'ECParameters'{} </v>
    </type>
  <desc>
    <p>Generates a new keypair</p>
  </desc>
  </func>

  <func>
    <name>pem_decode(PemBin) -> [pem_entry()]</name>
    <fsummary>Decode PEM binary data and return
    entries as ASN.1 DER encoded entities. </fsummary>
    <type>
      <v>PemBin = binary()</v>
      <d>Example {ok, PemBin} = file:read_file("cert.pem").</d>
    </type> 
  <desc> 
    <p>Decode PEM binary data and return
    entries as ASN.1 DER encoded entities.</p>
  </desc> 
  </func> 
    
   <func>
    <name>pem_encode(PemEntries) -> binary()</name>
    <fsummary>Creates a PEM binary</fsummary>
    <type>
      <v> PemEntries = [pem_entry()] </v> 
  </type> 
  <desc> 
    <p>Creates a PEM binary</p> 
  </desc> 
  </func>

   <func>
    <name>pem_entry_decode(PemEntry) -> term()</name>
    <name>pem_entry_decode(PemEntry, Password) -> term()</name>
    <fsummary>Decodes a pem entry.</fsummary>
    <type>
      <v> PemEntry = pem_entry() </v> 
      <v> Password = string() </v> 
  </type> 
  <desc> 
    <p>Decodes a PEM entry. pem_decode/1 returns a list of PEM
    entries. Note that if the PEM entry is of type
    'SubjectPublickeyInfo' it will be further decoded to an
    rsa_public_key() or dsa_public_key().</p>
  </desc> 
  </func>

   <func>
    <name>pem_entry_encode(Asn1Type, Entity) -> pem_entry()</name>
    <name>pem_entry_encode(Asn1Type, Entity, {CipherInfo, Password}) -> pem_entry()</name>
    <fsummary> Creates a PEM entry that can be fed to pem_encode/1.</fsummary>
    <type>
      <v>Asn1Type = pki_asn1_type()</v>
      <v>Entity = term()</v>
      <d>The Erlang representation of
      <c>Asn1Type</c>.  If <c>Asn1Type</c> is 'SubjectPublicKeyInfo'
      then <c>Entity</c> must be either an rsa_public_key() or a
      dsa_public_key() and this function will create the appropriate
      'SubjectPublicKeyInfo' entry.
      </d>
      <v>CipherInfo = cipher_info()</v>
      <v>Password = string()</v> 
  </type> 
  <desc> 
    <p> Creates a PEM entry that can be feed to pem_encode/1.</p>
  </desc> 
  </func>

  <func>
    <name>encrypt_private(PlainText, Key) -> binary()</name>
    <fsummary> Public key encryption using the private key.</fsummary>
    <type>
      <v>PlainText = binary()</v>
      <v>Key = rsa_private_key()</v> 
  </type> 
  <desc> 
    <p> Public key encryption using the private key.</p> 
  </desc> 
  </func>   

  <func>
    <name>encrypt_public(PlainText, Key) -> binary()</name>
    <fsummary> Public key encryption using the public key.</fsummary>
    <type>
      <v>PlainText = binary()</v>
      <v>Key = rsa_public_key()</v> 
  </type> 
  <desc> 
    <p> Public key encryption using the public key.</p> 
  </desc> 
  </func>   
  
  <func>
    <name>pkix_decode_cert(Cert, otp|plain) ->  #'Certificate'{} | #'OTPCertificate'{}</name>
    <fsummary> Decodes an ASN.1 DER encoded PKIX x509 certificate.</fsummary>
    <type>
      <v>Cert = der_encoded()</v> 
  </type> 
  <desc> 
    <p>Decodes an ASN.1 DER encoded PKIX certificate.  The otp option
    will use the customized ASN.1 specification OTP-PKIX.asn1 for
    decoding and also recursively decode most of the standard
    parts.</p>
  </desc> 
  </func>

  <func>
    <name>pkix_encode(Asn1Type, Entity, otp | plain) -> der_encoded()</name>
    <fsummary>DER encodes a PKIX x509 certificate or part of such a
    certificate.</fsummary>
    <type>
      <v>Asn1Type = atom()</v>
      <d>The ASN.1 type can be 'Certificate', 'OTPCertificate' or a subtype of either .</d>
      <v>Entity = #'Certificate'{} | #'OTPCertificate'{} | a valid subtype</v>
  </type> 
  <desc> 
    <p>DER encodes a PKIX x509 certificate or part of such a
    certificate. This function must be used for encoding certificates or parts of certificates
    that are decoded/created in the otp format, whereas for the plain format this
    function will directly call der_encode/2. </p> 
  </desc> 
  </func>

 <func>
    <name>pkix_is_issuer(Cert, IssuerCert) -> boolean()</name>
    <fsummary> Checks if <c>IssuerCert</c> issued <c>Cert</c> </fsummary>
    <type>
      <v>Cert = der_encode() | #'OTPCertificate'{}</v> 
      <v>IssuerCert = der_encode() | #'OTPCertificate'{}</v> 
  </type> 
  <desc> 
    <p> Checks if <c>IssuerCert</c> issued <c>Cert</c> </p> 
  </desc> 
  </func>
  
  <func>
    <name>pkix_is_fixed_dh_cert(Cert) -> boolean()</name>
    <fsummary> Checks if a Certificate is a fixed Diffie-Hellman Cert.</fsummary>
    <type>
        <v>Cert = der_encode() | #'OTPCertificate'{}</v> 
  </type> 
  <desc> 
    <p> Checks if a Certificate is a fixed Diffie-Hellman Cert.</p> 
  </desc> 
  </func>  
  
  <func>
    <name>pkix_is_self_signed(Cert) -> boolean()</name>
    <fsummary> Checks if a Certificate is self signed.</fsummary>
    <type>
       <v>Cert = der_encode() | #'OTPCertificate'{}</v> 
  </type> 
  <desc> 
    <p> Checks if a Certificate is self signed.</p> 
  </desc> 
  </func>

  <func>
    <name>pkix_issuer_id(Cert, IssuedBy) -> {ok, IssuerID} | {error, Reason}</name>
    <fsummary> Returns the issuer id.</fsummary>
    <type>
        <v>Cert = der_encode() | #'OTPCertificate'{}</v>
	<v>IssuedBy = self | other</v>
	<v>IssuerID = {integer(), {rdnSequence, [#'AttributeTypeAndValue'{}]}}</v>
	<d>The issuer id consists of the serial number and the issuers name.</d>
	<v>Reason = term()</v>
  </type> 
  <desc> 
    <p> Returns the issuer id.</p> 
  </desc> 
  </func>

  <func>
    <name>pkix_normalize_name(Issuer) -> Normalized</name>
    <fsummary>Normalizes a issuer name so that it can be easily
    compared to another issuer name. </fsummary>
    <type>
      <v>Issuer = {rdnSequence,[#'AttributeTypeAndValue'{}]}</v>
      <v>Normalized = {rdnSequence, [#'AttributeTypeAndValue'{}]}</v>
  </type> 
  <desc> 
    <p>Normalizes a issuer name so that it can be easily
    compared to another issuer name.</p> 
  </desc> 
  </func>
   
  <func>
    <name>pkix_path_validation(TrustedCert, CertChain, Options) -> {ok, {PublicKeyInfo, PolicyTree}} | {error, {bad_cert, Reason}} </name>
    <fsummary> Performs a basic path validation according to RFC 5280.</fsummary>
     <type>
       <v> TrustedCert =  #'OTPCertificate'{} | der_encode() | unknown_ca | selfsigned_peer  </v>
       <d>Normally a trusted certificate but it can also be one of the path validation
       errors <c>unknown_ca </c> or <c>selfsigned_peer </c> that can be discovered while
       constructing the input to this function and that should be run through the <c>verify_fun</c>.</d>
       <v> CertChain = [der_encode()]</v>
       <d>A list of DER encoded certificates in trust order ending with the peer certificate.</d>
       <v> Options = proplists:proplists()</v>
       <v>PublicKeyInfo = {?'rsaEncryption' | ?'id-dsa',
       rsa_public_key() | integer(), 'NULL' | 'Dss-Parms'{}}</v>
       <v> PolicyTree = term() </v>
       <d>At the moment this will always be an empty list as Policies are not currently supported</d>
       <v> Reason = cert_expired | invalid_issuer | invalid_signature | unknown_ca |
       selfsigned_peer | name_not_permitted | missing_basic_constraint | invalid_key_usage | crl_reason()
       </v>
     </type>
     <desc>
       <p>
	 Performs a basic path validation according to
	 <url href="http://www.ietf.org/rfc/rfc5280.txt">RFC 5280.</url>
	 However CRL validation is done separately by <seealso
	 marker="public_key#pkix_crls_validate-3">pkix_crls_validate/3 </seealso> and should be called
	 from the supplied <c>verify_fun</c>
       </p>

       <taglist>
	 <p> Available options are: </p>

	<tag>{verify_fun, fun()}</tag>
	<item>
	  <p>The fun should be defined as:</p>

	  <code>
fun(OtpCert :: #'OTPCertificate'{}, Event :: {bad_cert, Reason :: atom()} |
	                                     {extension, #'Extension'{}},
    InitialUserState :: term()) ->
	{valid, UserState :: term()} | {valid_peer, UserState :: term()} |
	{fail, Reason :: term()} | {unknown, UserState :: term()}.
	  </code>

	<p>If the verify callback fun returns {fail, Reason}, the
	verification process is immediately stopped. If the verify
	callback fun returns {valid, UserState}, the verification
	process is continued, this can be used to accept specific path
	validation errors such as <c>selfsigned_peer</c> as well as
	verifying application specific extensions.  If called with an
	extension unknown to the user application the return value
	{unknown, UserState} should be used.</p>

	</item>
	<tag>{max_path_length, integer()}</tag>
	<item>
	  The <c>max_path_length</c> is the maximum number of non-self-issued
	  intermediate certificates that may follow the peer certificate
	  in a valid certification path.  So if <c>max_path_length</c> is 0 the PEER must
	  be signed by the trusted ROOT-CA directly, if 1 the path can
	  be PEER, CA, ROOT-CA, if it is 2 PEER, CA, CA, ROOT-CA and so
	  on.
	</item>
      </taglist>
    </desc>
   </func>

   <func>
     <name>pkix_crls_validate(OTPCertificate, DPAndCRLs, Options) -> CRLStatus()</name>
     <fsummary> Performs CRL validation.</fsummary>
     <type>
       <v> OTPCertificate =  #'OTPCertificate'{}</v>
       <v> DPAndCRLs  = [{DP::#'DistributionPoint'{} ,CRL::#'CertificateList'{}}] </v>
       <v> Options = proplists:proplists()</v>
       <v> CRLStatus() =  valid | {bad_cert, revocation_status_undetermined} |
       {bad_cert, {revoked, crl_reason()}}</v>
     </type>
     <desc>
      <p> Performs CRL validation. It is intended to be called from
      the verify fun of  <seealso marker="public_key#pkix_path_validation-3"> pkix_path_validation/3
       </seealso></p>
      <taglist>
	<p> Available options are: </p>
	<tag>{update_crl, fun()}</tag>
	<item>
	  <p>The fun has the following type spec:</p>

	  <code> fun(#'DistributionPoint'{}, #'CertificateList'{}) -> #'CertificateList'{}</code>

	  <p>The fun should use the information in the distribution point to acesses
	  the lates possible version of the CRL. If this fun is not specified
	  public_key will use the default implementation:
	  </p>
	  <code> fun(_DP, CRL) -> CRL end</code>
	</item>
      </taglist>
    </desc>
   </func>

  <func>
    <name>pkix_sign(#'OTPTBSCertificate'{}, Key) -> der_encode()</name>
    <fsummary>Signs certificate.</fsummary>
    <type>
      <v>Key = rsa_public_key() | dsa_public_key()</v> 
    </type> 
    <desc> 
      <p>Signs a 'OTPTBSCertificate'. Returns the corresponding
      der encoded certificate.</p> 
    </desc> 
  </func> 

  <func>
    <name>pkix_sign_types(AlgorithmId) -> {DigestType, SignatureType}</name>
    <fsummary>Translates signature algorithm oid to erlang digest and signature algorithm types.</fsummary>
    <type>
      <v>AlgorithmId = oid()</v>
      <d>Signature oid from a certificate or a certificate revocation list</d>
      <v>DigestType = rsa_digest_type() | dss_digest_type() </v>
      <v>SignatureType = rsa | dsa</v>
    </type>
    <desc>
      <p>Translates signature algorithm oid to erlang digest and signature types.
      </p>
    </desc>
  </func>

  <func>  
    <name>pkix_verify(Cert, Key) -> boolean()</name>
    <fsummary> Verify pkix x.509 certificate signature.</fsummary>
    <type>
      <v>Cert = der_encode()</v> 
      <v>Key = rsa_public_key() | dsa_public_key()</v> 
    </type> 
  <desc> 
    <p> Verify PKIX x.509 certificate signature.</p>
  </desc> 
  </func> 

  <func>
    <name>sign(Msg, DigestType, Key) -> binary()</name>
    <fsummary> Create digital signature.</fsummary>
    <type>
       <v>Msg = binary() | {digest,binary()}</v>
       <d>The msg is either the binary "plain text" data to be
       signed or it is the hashed value of "plain text" i.e. the
       digest.</d>
       <v>DigestType = rsa_digest_type() | dss_digest_type() | ecdsa_digest_type()</v>
       <v>Key = rsa_private_key() | dsa_private_key() | ec_private_key()</v>
  </type>
  <desc>
    <p> Creates a digital signature.</p> 
  </desc> 
  </func>   

  <func>
    <name>ssh_decode(SshBin,  Type) -> [{public_key(), Attributes::list()}]</name>
    <fsummary>Decodes a ssh file-binary. </fsummary>
    <type>
      <v>SshBin = binary()</v>
      <d>Example {ok, SshBin} = file:read_file("known_hosts").</d>
      <v> Type = public_key | ssh_file()</v>
      <d>If <c>Type</c> is <c>public_key</c> the binary may be either
      a rfc4716 public key or a openssh public key.</d>
    </type>
  <desc>
    <p> Decodes a ssh file-binary. In the case of know_hosts or
    auth_keys the binary may include one or more lines of the
    file. Returns a list of public keys and their attributes, possible
    attribute values depends on the file type represented by the
    binary.
    </p>

    <taglist>
      <tag>rfc4716 attributes - see RFC 4716</tag>
      <item>{headers, [{string(), utf8_string()}]}</item>
      <tag>auth_key attributes - see man sshd </tag>
      <item>{comment, string()}</item>
      <item>{options, [string()]}</item>
      <item>{bits, integer()} - In ssh version 1 files</item>
      <tag>known_host attributes - see man sshd</tag>
      <item>{hostnames, [string()]}</item>
      <item>{comment, string()}</item>
      <item>{bits, integer()} - In ssh version 1 files</item>
    </taglist>

  </desc>
  </func>

  <func>
    <name>ssh_encode([{Key, Attributes}], Type) -> binary()</name>
    <fsummary> Encodes a list of ssh file entries to a binary.</fsummary>
    <type>
      <v>Key = public_key()</v>
      <v>Attributes = list()</v>
      <v>Type = ssh_file()</v>
    </type>
  <desc>
    <p>Encodes a list of ssh file entries (public keys and attributes) to a binary. Possible
    attributes depends on the file type, see <seealso
    marker="#ssh_decode-2"> ssh_decode/2 </seealso></p>
  </desc>
  </func>

  <func>
    <name>verify(Msg, DigestType, Signature, Key) -> boolean()</name>
    <fsummary>Verifies a digital signature.</fsummary>
    <type>
      <v>Msg = binary() | {digest,binary()}</v>
       <d>The msg is either the binary "plain text" data 
        or it is the hashed value of "plain text" i.e. the digest.</d>
      <v>DigestType = rsa_digest_type() | dss_digest_type() | ecdsa_digest_type()</v>
      <v>Signature = binary()</v>
      <v>Key = rsa_public_key() | dsa_public_key() | ec_public_key()</v>
  </type>
  <desc>
    <p>Verifies a digital signature</p>
  </desc> 
  </func>
  
</funcs>

</erlref>