~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-security

« back to all changes in this revision

Viewing changes to doc/src/sgml/html/pgcrypto.html

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-05-11 10:41:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110511104153-psbh2o58553fv1m0
Tags: upstream-9.1~beta1
ImportĀ upstreamĀ versionĀ 9.1~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 
2
<HTML
 
3
><HEAD
 
4
><TITLE
 
5
>pgcrypto</TITLE
 
6
><META
 
7
NAME="GENERATOR"
 
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
 
9
REV="MADE"
 
10
HREF="mailto:pgsql-docs@postgresql.org"><LINK
 
11
REL="HOME"
 
12
TITLE="PostgreSQL 9.1beta1 Documentation"
 
13
HREF="index.html"><LINK
 
14
REL="UP"
 
15
TITLE="Additional Supplied Modules"
 
16
HREF="contrib.html"><LINK
 
17
REL="PREVIOUS"
 
18
TITLE="pg_buffercache"
 
19
HREF="pgbuffercache.html"><LINK
 
20
REL="NEXT"
 
21
TITLE="pg_freespacemap"
 
22
HREF="pgfreespacemap.html"><LINK
 
23
REL="STYLESHEET"
 
24
TYPE="text/css"
 
25
HREF="stylesheet.css"><META
 
26
HTTP-EQUIV="Content-Type"
 
27
CONTENT="text/html; charset=ISO-8859-1"><META
 
28
NAME="creation"
 
29
CONTENT="2011-04-27T21:20:33"></HEAD
 
30
><BODY
 
31
CLASS="SECT1"
 
32
><DIV
 
33
CLASS="NAVHEADER"
 
34
><TABLE
 
35
SUMMARY="Header navigation table"
 
36
WIDTH="100%"
 
37
BORDER="0"
 
38
CELLPADDING="0"
 
39
CELLSPACING="0"
 
40
><TR
 
41
><TH
 
42
COLSPAN="5"
 
43
ALIGN="center"
 
44
VALIGN="bottom"
 
45
><A
 
46
HREF="index.html"
 
47
>PostgreSQL 9.1beta1 Documentation</A
 
48
></TH
 
49
></TR
 
50
><TR
 
51
><TD
 
52
WIDTH="10%"
 
53
ALIGN="left"
 
54
VALIGN="top"
 
55
><A
 
56
TITLE="pg_buffercache"
 
57
HREF="pgbuffercache.html"
 
58
ACCESSKEY="P"
 
59
>Prev</A
 
60
></TD
 
61
><TD
 
62
WIDTH="10%"
 
63
ALIGN="left"
 
64
VALIGN="top"
 
65
><A
 
66
TITLE="Additional Supplied Modules"
 
67
HREF="contrib.html"
 
68
>Fast Backward</A
 
69
></TD
 
70
><TD
 
71
WIDTH="60%"
 
72
ALIGN="center"
 
73
VALIGN="bottom"
 
74
>Appendix F. Additional Supplied Modules</TD
 
75
><TD
 
76
WIDTH="10%"
 
77
ALIGN="right"
 
78
VALIGN="top"
 
79
><A
 
80
TITLE="Additional Supplied Modules"
 
81
HREF="contrib.html"
 
82
>Fast Forward</A
 
83
></TD
 
84
><TD
 
85
WIDTH="10%"
 
86
ALIGN="right"
 
87
VALIGN="top"
 
88
><A
 
89
TITLE="pg_freespacemap"
 
90
HREF="pgfreespacemap.html"
 
91
ACCESSKEY="N"
 
92
>Next</A
 
93
></TD
 
94
></TR
 
95
></TABLE
 
96
><HR
 
97
ALIGN="LEFT"
 
98
WIDTH="100%"></DIV
 
99
><DIV
 
100
CLASS="SECT1"
 
101
><H1
 
102
CLASS="SECT1"
 
103
><A
 
104
NAME="PGCRYPTO"
 
105
>F.28. pgcrypto</A
 
106
></H1
 
107
><P
 
108
>  The <TT
 
109
CLASS="FILENAME"
 
110
>pgcrypto</TT
 
111
> module provides cryptographic functions for
 
112
  <SPAN
 
113
CLASS="PRODUCTNAME"
 
114
>PostgreSQL</SPAN
 
115
>.
 
116
 </P
 
117
><DIV
 
118
CLASS="SECT2"
 
119
><H2
 
120
CLASS="SECT2"
 
121
><A
 
122
NAME="AEN132623"
 
123
>F.28.1. General Hashing Functions</A
 
124
></H2
 
125
><DIV
 
126
CLASS="SECT3"
 
127
><H3
 
128
CLASS="SECT3"
 
129
><A
 
130
NAME="AEN132625"
 
131
>F.28.1.1. <CODE
 
132
CLASS="FUNCTION"
 
133
>digest()</CODE
 
134
></A
 
135
></H3
 
136
><PRE
 
137
CLASS="SYNOPSIS"
 
138
>digest(data text, type text) returns bytea
 
139
digest(data bytea, type text) returns bytea</PRE
 
140
><P
 
141
>    Computes a binary hash of the given <TT
 
142
CLASS="PARAMETER"
 
143
>data</TT
 
144
>.
 
145
    <TT
 
146
CLASS="PARAMETER"
 
147
>type</TT
 
148
> is the algorithm to use.
 
149
    Standard algorithms are <TT
 
150
CLASS="LITERAL"
 
151
>md5</TT
 
152
>, <TT
 
153
CLASS="LITERAL"
 
154
>sha1</TT
 
155
>,
 
156
    <TT
 
157
CLASS="LITERAL"
 
158
>sha224</TT
 
159
>, <TT
 
160
CLASS="LITERAL"
 
161
>sha256</TT
 
162
>,
 
163
    <TT
 
164
CLASS="LITERAL"
 
165
>sha384</TT
 
166
> and <TT
 
167
CLASS="LITERAL"
 
168
>sha512</TT
 
169
>.
 
170
    If <TT
 
171
CLASS="FILENAME"
 
172
>pgcrypto</TT
 
173
> was built with
 
174
    OpenSSL, more algorithms are available, as detailed in
 
175
    <A
 
176
HREF="pgcrypto.html#PGCRYPTO-WITH-WITHOUT-OPENSSL"
 
177
>Table F-18</A
 
178
>.
 
179
   </P
 
180
><P
 
181
>    If you want the digest as a hexadecimal string, use
 
182
    <CODE
 
183
CLASS="FUNCTION"
 
184
>encode()</CODE
 
185
> on the result.  For example:
 
186
</P><PRE
 
187
CLASS="PROGRAMLISTING"
 
188
>CREATE OR REPLACE FUNCTION sha1(bytea) returns text AS $$
 
189
    SELECT encode(digest($1, 'sha1'), 'hex')
 
190
$$ LANGUAGE SQL STRICT IMMUTABLE;</PRE
 
191
><P>
 
192
   </P
 
193
></DIV
 
194
><DIV
 
195
CLASS="SECT3"
 
196
><H3
 
197
CLASS="SECT3"
 
198
><A
 
199
NAME="AEN132643"
 
200
>F.28.1.2. <CODE
 
201
CLASS="FUNCTION"
 
202
>hmac()</CODE
 
203
></A
 
204
></H3
 
205
><PRE
 
206
CLASS="SYNOPSIS"
 
207
>hmac(data text, key text, type text) returns bytea
 
208
hmac(data bytea, key text, type text) returns bytea</PRE
 
209
><P
 
210
>    Calculates hashed MAC for <TT
 
211
CLASS="PARAMETER"
 
212
>data</TT
 
213
> with key <TT
 
214
CLASS="PARAMETER"
 
215
>key</TT
 
216
>.
 
217
    <TT
 
218
CLASS="PARAMETER"
 
219
>type</TT
 
220
> is the same as in <CODE
 
221
CLASS="FUNCTION"
 
222
>digest()</CODE
 
223
>.
 
224
   </P
 
225
><P
 
226
>    This is similar to <CODE
 
227
CLASS="FUNCTION"
 
228
>digest()</CODE
 
229
> but the hash can only be
 
230
    recalculated knowing the key.  This prevents the scenario of someone
 
231
    altering data and also changing the hash to match.
 
232
   </P
 
233
><P
 
234
>    If the key is larger than the hash block size it will first be hashed and
 
235
    the result will be used as key.
 
236
   </P
 
237
></DIV
 
238
></DIV
 
239
><DIV
 
240
CLASS="SECT2"
 
241
><H2
 
242
CLASS="SECT2"
 
243
><A
 
244
NAME="AEN132655"
 
245
>F.28.2. Password Hashing Functions</A
 
246
></H2
 
247
><P
 
248
>   The functions <CODE
 
249
CLASS="FUNCTION"
 
250
>crypt()</CODE
 
251
> and <CODE
 
252
CLASS="FUNCTION"
 
253
>gen_salt()</CODE
 
254
>
 
255
   are specifically designed for hashing passwords.
 
256
   <CODE
 
257
CLASS="FUNCTION"
 
258
>crypt()</CODE
 
259
> does the hashing and <CODE
 
260
CLASS="FUNCTION"
 
261
>gen_salt()</CODE
 
262
>
 
263
   prepares algorithm parameters for it.
 
264
  </P
 
265
><P
 
266
>   The algorithms in <CODE
 
267
CLASS="FUNCTION"
 
268
>crypt()</CODE
 
269
> differ from usual hashing algorithms
 
270
   like MD5 or SHA1 in the following respects:
 
271
  </P
 
272
><P
 
273
></P
 
274
><OL
 
275
TYPE="1"
 
276
><LI
 
277
><P
 
278
>     They are slow.  As the amount of data is so small, this is the only
 
279
     way to make brute-forcing passwords hard.
 
280
    </P
 
281
></LI
 
282
><LI
 
283
><P
 
284
>     They use a random value, called the <I
 
285
CLASS="FIRSTTERM"
 
286
>salt</I
 
287
>, so that users
 
288
     having the same password will have different encrypted passwords.
 
289
     This is also an additional defense against reversing the algorithm.
 
290
    </P
 
291
></LI
 
292
><LI
 
293
><P
 
294
>     They include the algorithm type in the result, so passwords hashed with
 
295
     different algorithms can co-exist.
 
296
    </P
 
297
></LI
 
298
><LI
 
299
><P
 
300
>     Some of them are adaptive &mdash; that means when computers get
 
301
     faster, you can tune the algorithm to be slower, without
 
302
     introducing incompatibility with existing passwords.
 
303
    </P
 
304
></LI
 
305
></OL
 
306
><P
 
307
>   <A
 
308
HREF="pgcrypto.html#PGCRYPTO-CRYPT-ALGORITHMS"
 
309
>Table F-15</A
 
310
> lists the algorithms
 
311
   supported by the <CODE
 
312
CLASS="FUNCTION"
 
313
>crypt()</CODE
 
314
> function.
 
315
  </P
 
316
><DIV
 
317
CLASS="TABLE"
 
318
><A
 
319
NAME="PGCRYPTO-CRYPT-ALGORITHMS"
 
320
></A
 
321
><P
 
322
><B
 
323
>Table F-15. Supported Algorithms for <CODE
 
324
CLASS="FUNCTION"
 
325
>crypt()</CODE
 
326
></B
 
327
></P
 
328
><TABLE
 
329
BORDER="1"
 
330
CLASS="CALSTABLE"
 
331
><COL><COL><COL><COL><COL><THEAD
 
332
><TR
 
333
><TH
 
334
>Algorithm</TH
 
335
><TH
 
336
>Max Password Length</TH
 
337
><TH
 
338
>Adaptive?</TH
 
339
><TH
 
340
>Salt Bits</TH
 
341
><TH
 
342
>Description</TH
 
343
></TR
 
344
></THEAD
 
345
><TBODY
 
346
><TR
 
347
><TD
 
348
><TT
 
349
CLASS="LITERAL"
 
350
>bf</TT
 
351
></TD
 
352
><TD
 
353
>72</TD
 
354
><TD
 
355
>yes</TD
 
356
><TD
 
357
>128</TD
 
358
><TD
 
359
>Blowfish-based, variant 2a</TD
 
360
></TR
 
361
><TR
 
362
><TD
 
363
><TT
 
364
CLASS="LITERAL"
 
365
>md5</TT
 
366
></TD
 
367
><TD
 
368
>unlimited</TD
 
369
><TD
 
370
>no</TD
 
371
><TD
 
372
>48</TD
 
373
><TD
 
374
>MD5-based crypt</TD
 
375
></TR
 
376
><TR
 
377
><TD
 
378
><TT
 
379
CLASS="LITERAL"
 
380
>xdes</TT
 
381
></TD
 
382
><TD
 
383
>8</TD
 
384
><TD
 
385
>yes</TD
 
386
><TD
 
387
>24</TD
 
388
><TD
 
389
>Extended DES</TD
 
390
></TR
 
391
><TR
 
392
><TD
 
393
><TT
 
394
CLASS="LITERAL"
 
395
>des</TT
 
396
></TD
 
397
><TD
 
398
>8</TD
 
399
><TD
 
400
>no</TD
 
401
><TD
 
402
>12</TD
 
403
><TD
 
404
>Original UNIX crypt</TD
 
405
></TR
 
406
></TBODY
 
407
></TABLE
 
408
></DIV
 
409
><DIV
 
410
CLASS="SECT3"
 
411
><H3
 
412
CLASS="SECT3"
 
413
><A
 
414
NAME="AEN132717"
 
415
>F.28.2.1. <CODE
 
416
CLASS="FUNCTION"
 
417
>crypt()</CODE
 
418
></A
 
419
></H3
 
420
><PRE
 
421
CLASS="SYNOPSIS"
 
422
>crypt(password text, salt text) returns text</PRE
 
423
><P
 
424
>    Calculates a crypt(3)-style hash of <TT
 
425
CLASS="PARAMETER"
 
426
>password</TT
 
427
>.
 
428
    When storing a new password, you need to use
 
429
    <CODE
 
430
CLASS="FUNCTION"
 
431
>gen_salt()</CODE
 
432
> to generate a new <TT
 
433
CLASS="PARAMETER"
 
434
>salt</TT
 
435
> value.
 
436
    To check a password, pass the stored hash value as <TT
 
437
CLASS="PARAMETER"
 
438
>salt</TT
 
439
>,
 
440
    and test whether the result matches the stored value.
 
441
   </P
 
442
><P
 
443
>    Example of setting a new password:
 
444
</P><PRE
 
445
CLASS="PROGRAMLISTING"
 
446
>UPDATE ... SET pswhash = crypt('new password', gen_salt('md5'));</PRE
 
447
><P>
 
448
   </P
 
449
><P
 
450
>    Example of authentication:
 
451
</P><PRE
 
452
CLASS="PROGRAMLISTING"
 
453
>SELECT pswhash = crypt('entered password', pswhash) FROM ... ;</PRE
 
454
><P>
 
455
    This returns <TT
 
456
CLASS="LITERAL"
 
457
>true</TT
 
458
> if the entered password is correct.
 
459
   </P
 
460
></DIV
 
461
><DIV
 
462
CLASS="SECT3"
 
463
><H3
 
464
CLASS="SECT3"
 
465
><A
 
466
NAME="AEN132731"
 
467
>F.28.2.2. <CODE
 
468
CLASS="FUNCTION"
 
469
>gen_salt()</CODE
 
470
></A
 
471
></H3
 
472
><PRE
 
473
CLASS="SYNOPSIS"
 
474
>gen_salt(type text [, iter_count integer ]) returns text</PRE
 
475
><P
 
476
>    Generates a new random salt string for use in <CODE
 
477
CLASS="FUNCTION"
 
478
>crypt()</CODE
 
479
>.
 
480
    The salt string also tells <CODE
 
481
CLASS="FUNCTION"
 
482
>crypt()</CODE
 
483
> which algorithm to use.
 
484
   </P
 
485
><P
 
486
>    The <TT
 
487
CLASS="PARAMETER"
 
488
>type</TT
 
489
> parameter specifies the hashing algorithm.
 
490
    The accepted types are: <TT
 
491
CLASS="LITERAL"
 
492
>des</TT
 
493
>, <TT
 
494
CLASS="LITERAL"
 
495
>xdes</TT
 
496
>,
 
497
    <TT
 
498
CLASS="LITERAL"
 
499
>md5</TT
 
500
> and <TT
 
501
CLASS="LITERAL"
 
502
>bf</TT
 
503
>.
 
504
   </P
 
505
><P
 
506
>    The <TT
 
507
CLASS="PARAMETER"
 
508
>iter_count</TT
 
509
> parameter lets the user specify the iteration
 
510
    count, for algorithms that have one.
 
511
    The higher the count, the more time it takes to hash
 
512
    the password and therefore the more time to break it.  Although with
 
513
    too high a count the time to calculate a hash may be several years
 
514
    &mdash; which is somewhat impractical.  If the <TT
 
515
CLASS="PARAMETER"
 
516
>iter_count</TT
 
517
>
 
518
    parameter is omitted, the default iteration count is used.
 
519
    Allowed values for <TT
 
520
CLASS="PARAMETER"
 
521
>iter_count</TT
 
522
> depend on the algorithm and
 
523
    are shown in <A
 
524
HREF="pgcrypto.html#PGCRYPTO-ICFC-TABLE"
 
525
>Table F-16</A
 
526
>.
 
527
   </P
 
528
><DIV
 
529
CLASS="TABLE"
 
530
><A
 
531
NAME="PGCRYPTO-ICFC-TABLE"
 
532
></A
 
533
><P
 
534
><B
 
535
>Table F-16. Iteration Counts for <CODE
 
536
CLASS="FUNCTION"
 
537
>crypt()</CODE
 
538
></B
 
539
></P
 
540
><TABLE
 
541
BORDER="1"
 
542
CLASS="CALSTABLE"
 
543
><COL><COL><COL><COL><THEAD
 
544
><TR
 
545
><TH
 
546
>Algorithm</TH
 
547
><TH
 
548
>Default</TH
 
549
><TH
 
550
>Min</TH
 
551
><TH
 
552
>Max</TH
 
553
></TR
 
554
></THEAD
 
555
><TBODY
 
556
><TR
 
557
><TD
 
558
><TT
 
559
CLASS="LITERAL"
 
560
>xdes</TT
 
561
></TD
 
562
><TD
 
563
>725</TD
 
564
><TD
 
565
>1</TD
 
566
><TD
 
567
>16777215</TD
 
568
></TR
 
569
><TR
 
570
><TD
 
571
><TT
 
572
CLASS="LITERAL"
 
573
>bf</TT
 
574
></TD
 
575
><TD
 
576
>6</TD
 
577
><TD
 
578
>4</TD
 
579
><TD
 
580
>31</TD
 
581
></TR
 
582
></TBODY
 
583
></TABLE
 
584
></DIV
 
585
><P
 
586
>    For <TT
 
587
CLASS="LITERAL"
 
588
>xdes</TT
 
589
> there is an additional limitation that the
 
590
    iteration count must be an odd number.
 
591
   </P
 
592
><P
 
593
>    To pick an appropriate iteration count, consider that
 
594
    the original DES crypt was designed to have the speed of 4 hashes per
 
595
    second on the hardware of that time.
 
596
    Slower than 4 hashes per second would probably dampen usability.
 
597
    Faster than 100 hashes per second is probably too fast.
 
598
   </P
 
599
><P
 
600
>    <A
 
601
HREF="pgcrypto.html#PGCRYPTO-HASH-SPEED-TABLE"
 
602
>Table F-17</A
 
603
> gives an overview of the relative slowness
 
604
    of different hashing algorithms.
 
605
    The table shows how much time it would take to try all
 
606
    combinations of characters in an 8-character password, assuming
 
607
    that the password contains either only lower case letters, or
 
608
    upper- and lower-case letters and numbers.
 
609
    In the <TT
 
610
CLASS="LITERAL"
 
611
>crypt-bf</TT
 
612
> entries, the number after a slash is
 
613
    the <TT
 
614
CLASS="PARAMETER"
 
615
>iter_count</TT
 
616
> parameter of
 
617
    <CODE
 
618
CLASS="FUNCTION"
 
619
>gen_salt</CODE
 
620
>.
 
621
   </P
 
622
><DIV
 
623
CLASS="TABLE"
 
624
><A
 
625
NAME="PGCRYPTO-HASH-SPEED-TABLE"
 
626
></A
 
627
><P
 
628
><B
 
629
>Table F-17. Hash Algorithm Speeds</B
 
630
></P
 
631
><TABLE
 
632
BORDER="1"
 
633
CLASS="CALSTABLE"
 
634
><COL><COL><COL><COL><THEAD
 
635
><TR
 
636
><TH
 
637
>Algorithm</TH
 
638
><TH
 
639
>Hashes/sec</TH
 
640
><TH
 
641
>For <TT
 
642
CLASS="LITERAL"
 
643
>[a-z]</TT
 
644
></TH
 
645
><TH
 
646
>For <TT
 
647
CLASS="LITERAL"
 
648
>[A-Za-z0-9]</TT
 
649
></TH
 
650
></TR
 
651
></THEAD
 
652
><TBODY
 
653
><TR
 
654
><TD
 
655
><TT
 
656
CLASS="LITERAL"
 
657
>crypt-bf/8</TT
 
658
></TD
 
659
><TD
 
660
>28</TD
 
661
><TD
 
662
>246 years</TD
 
663
><TD
 
664
>251322 years</TD
 
665
></TR
 
666
><TR
 
667
><TD
 
668
><TT
 
669
CLASS="LITERAL"
 
670
>crypt-bf/7</TT
 
671
></TD
 
672
><TD
 
673
>57</TD
 
674
><TD
 
675
>121 years</TD
 
676
><TD
 
677
>123457 years</TD
 
678
></TR
 
679
><TR
 
680
><TD
 
681
><TT
 
682
CLASS="LITERAL"
 
683
>crypt-bf/6</TT
 
684
></TD
 
685
><TD
 
686
>112</TD
 
687
><TD
 
688
>62 years</TD
 
689
><TD
 
690
>62831 years</TD
 
691
></TR
 
692
><TR
 
693
><TD
 
694
><TT
 
695
CLASS="LITERAL"
 
696
>crypt-bf/5</TT
 
697
></TD
 
698
><TD
 
699
>211</TD
 
700
><TD
 
701
>33 years</TD
 
702
><TD
 
703
>33351 years</TD
 
704
></TR
 
705
><TR
 
706
><TD
 
707
><TT
 
708
CLASS="LITERAL"
 
709
>crypt-md5</TT
 
710
></TD
 
711
><TD
 
712
>2681</TD
 
713
><TD
 
714
>2.6 years</TD
 
715
><TD
 
716
>2625 years</TD
 
717
></TR
 
718
><TR
 
719
><TD
 
720
><TT
 
721
CLASS="LITERAL"
 
722
>crypt-des</TT
 
723
></TD
 
724
><TD
 
725
>362837</TD
 
726
><TD
 
727
>7 days</TD
 
728
><TD
 
729
>19 years</TD
 
730
></TR
 
731
><TR
 
732
><TD
 
733
><TT
 
734
CLASS="LITERAL"
 
735
>sha1</TT
 
736
></TD
 
737
><TD
 
738
>590223</TD
 
739
><TD
 
740
>4 days</TD
 
741
><TD
 
742
>12 years</TD
 
743
></TR
 
744
><TR
 
745
><TD
 
746
><TT
 
747
CLASS="LITERAL"
 
748
>md5</TT
 
749
></TD
 
750
><TD
 
751
>2345086</TD
 
752
><TD
 
753
>1 day</TD
 
754
><TD
 
755
>3 years</TD
 
756
></TR
 
757
></TBODY
 
758
></TABLE
 
759
></DIV
 
760
><P
 
761
>    Notes:
 
762
   </P
 
763
><P
 
764
></P
 
765
><UL
 
766
><LI
 
767
><P
 
768
>     The machine used is a 1.5GHz Pentium 4.
 
769
     </P
 
770
></LI
 
771
><LI
 
772
><P
 
773
>      <TT
 
774
CLASS="LITERAL"
 
775
>crypt-des</TT
 
776
> and <TT
 
777
CLASS="LITERAL"
 
778
>crypt-md5</TT
 
779
> algorithm numbers are
 
780
      taken from John the Ripper v1.6.38 <TT
 
781
CLASS="LITERAL"
 
782
>-test</TT
 
783
> output.
 
784
     </P
 
785
></LI
 
786
><LI
 
787
><P
 
788
>      <TT
 
789
CLASS="LITERAL"
 
790
>md5</TT
 
791
> numbers are from mdcrack 1.2.
 
792
     </P
 
793
></LI
 
794
><LI
 
795
><P
 
796
>      <TT
 
797
CLASS="LITERAL"
 
798
>sha1</TT
 
799
> numbers are from lcrack-20031130-beta.
 
800
     </P
 
801
></LI
 
802
><LI
 
803
><P
 
804
>      <TT
 
805
CLASS="LITERAL"
 
806
>crypt-bf</TT
 
807
> numbers are taken using a simple program that
 
808
      loops over 1000 8-character passwords.  That way I can show the speed
 
809
      with different numbers of iterations.  For reference: <TT
 
810
CLASS="LITERAL"
 
811
>john
 
812
      -test</TT
 
813
> shows 213 loops/sec for <TT
 
814
CLASS="LITERAL"
 
815
>crypt-bf/5</TT
 
816
>.
 
817
      (The very small
 
818
      difference in results is in accordance with the fact that the
 
819
      <TT
 
820
CLASS="LITERAL"
 
821
>crypt-bf</TT
 
822
> implementation in <TT
 
823
CLASS="FILENAME"
 
824
>pgcrypto</TT
 
825
>
 
826
      is the same one used in John the Ripper.)
 
827
     </P
 
828
></LI
 
829
></UL
 
830
><P
 
831
>    Note that <SPAN
 
832
CLASS="QUOTE"
 
833
>"try all combinations"</SPAN
 
834
> is not a realistic exercise.
 
835
    Usually password cracking is done with the help of dictionaries, which
 
836
    contain both regular words and various mutations of them.  So, even
 
837
    somewhat word-like passwords could be cracked much faster than the above
 
838
    numbers suggest, while a 6-character non-word-like password may escape
 
839
    cracking.  Or not.
 
840
   </P
 
841
></DIV
 
842
></DIV
 
843
><DIV
 
844
CLASS="SECT2"
 
845
><H2
 
846
CLASS="SECT2"
 
847
><A
 
848
NAME="AEN132864"
 
849
>F.28.3. PGP Encryption Functions</A
 
850
></H2
 
851
><P
 
852
>   The functions here implement the encryption part of the OpenPGP (RFC 4880)
 
853
   standard.  Supported are both symmetric-key and public-key encryption.
 
854
  </P
 
855
><P
 
856
>   An encrypted PGP message consists of 2 parts, or <I
 
857
CLASS="FIRSTTERM"
 
858
>packets</I
 
859
>:
 
860
  </P
 
861
><P
 
862
></P
 
863
><UL
 
864
><LI
 
865
><P
 
866
>     Packet containing a session key &mdash; either symmetric-key or public-key
 
867
     encrypted.
 
868
    </P
 
869
></LI
 
870
><LI
 
871
><P
 
872
>     Packet containing data encrypted with the session key.
 
873
    </P
 
874
></LI
 
875
></UL
 
876
><P
 
877
>   When encrypting with a symmetric key (i.e., a password):
 
878
  </P
 
879
><P
 
880
></P
 
881
><OL
 
882
TYPE="1"
 
883
><LI
 
884
><P
 
885
>     The given password is hashed using a String2Key (S2K) algorithm.  This is
 
886
     rather similar to <CODE
 
887
CLASS="FUNCTION"
 
888
>crypt()</CODE
 
889
> algorithms &mdash; purposefully
 
890
     slow and with random salt &mdash; but it produces a full-length binary
 
891
     key.
 
892
    </P
 
893
></LI
 
894
><LI
 
895
><P
 
896
>     If a separate session key is requested, a new random key will be
 
897
     generated.  Otherwise the S2K key will be used directly as the session
 
898
     key.
 
899
    </P
 
900
></LI
 
901
><LI
 
902
><P
 
903
>     If the S2K key is to be used directly, then only S2K settings will be put
 
904
     into the session key packet.  Otherwise the session key will be encrypted
 
905
     with the S2K key and put into the session key packet.
 
906
    </P
 
907
></LI
 
908
></OL
 
909
><P
 
910
>   When encrypting with a public key:
 
911
  </P
 
912
><P
 
913
></P
 
914
><OL
 
915
TYPE="1"
 
916
><LI
 
917
><P
 
918
>     A new random session key is generated.
 
919
    </P
 
920
></LI
 
921
><LI
 
922
><P
 
923
>     It is encrypted using the public key and put into the session key packet.
 
924
    </P
 
925
></LI
 
926
></OL
 
927
><P
 
928
>   In either case the data to be encrypted is processed as follows:
 
929
  </P
 
930
><P
 
931
></P
 
932
><OL
 
933
TYPE="1"
 
934
><LI
 
935
><P
 
936
>     Optional data-manipulation: compression, conversion to UTF-8,
 
937
     and/or conversion of line-endings.
 
938
    </P
 
939
></LI
 
940
><LI
 
941
><P
 
942
>     The data is prefixed with a block of random bytes.  This is equivalent
 
943
     to using a random IV.
 
944
    </P
 
945
></LI
 
946
><LI
 
947
><P
 
948
>     An SHA1 hash of the random prefix and data is appended.
 
949
    </P
 
950
></LI
 
951
><LI
 
952
><P
 
953
>     All this is encrypted with the session key and placed in the data packet.
 
954
    </P
 
955
></LI
 
956
></OL
 
957
><DIV
 
958
CLASS="SECT3"
 
959
><H3
 
960
CLASS="SECT3"
 
961
><A
 
962
NAME="AEN132899"
 
963
>F.28.3.1. <CODE
 
964
CLASS="FUNCTION"
 
965
>pgp_sym_encrypt()</CODE
 
966
></A
 
967
></H3
 
968
><PRE
 
969
CLASS="SYNOPSIS"
 
970
>pgp_sym_encrypt(data text, psw text [, options text ]) returns bytea
 
971
pgp_sym_encrypt_bytea(data bytea, psw text [, options text ]) returns bytea</PRE
 
972
><P
 
973
>    Encrypt <TT
 
974
CLASS="PARAMETER"
 
975
>data</TT
 
976
> with a symmetric PGP key <TT
 
977
CLASS="PARAMETER"
 
978
>psw</TT
 
979
>.
 
980
    The <TT
 
981
CLASS="PARAMETER"
 
982
>options</TT
 
983
> parameter can contain option settings,
 
984
    as described below.
 
985
   </P
 
986
></DIV
 
987
><DIV
 
988
CLASS="SECT3"
 
989
><H3
 
990
CLASS="SECT3"
 
991
><A
 
992
NAME="AEN132907"
 
993
>F.28.3.2. <CODE
 
994
CLASS="FUNCTION"
 
995
>pgp_sym_decrypt()</CODE
 
996
></A
 
997
></H3
 
998
><PRE
 
999
CLASS="SYNOPSIS"
 
1000
>pgp_sym_decrypt(msg bytea, psw text [, options text ]) returns text
 
1001
pgp_sym_decrypt_bytea(msg bytea, psw text [, options text ]) returns bytea</PRE
 
1002
><P
 
1003
>    Decrypt a symmetric-key-encrypted PGP message.
 
1004
   </P
 
1005
><P
 
1006
>    Decrypting <TT
 
1007
CLASS="TYPE"
 
1008
>bytea</TT
 
1009
> data with <CODE
 
1010
CLASS="FUNCTION"
 
1011
>pgp_sym_decrypt</CODE
 
1012
> is disallowed.
 
1013
    This is to avoid outputting invalid character data.  Decrypting
 
1014
    originally textual data with <CODE
 
1015
CLASS="FUNCTION"
 
1016
>pgp_sym_decrypt_bytea</CODE
 
1017
> is fine.
 
1018
   </P
 
1019
><P
 
1020
>    The <TT
 
1021
CLASS="PARAMETER"
 
1022
>options</TT
 
1023
> parameter can contain option settings,
 
1024
    as described below.
 
1025
   </P
 
1026
></DIV
 
1027
><DIV
 
1028
CLASS="SECT3"
 
1029
><H3
 
1030
CLASS="SECT3"
 
1031
><A
 
1032
NAME="AEN132918"
 
1033
>F.28.3.3. <CODE
 
1034
CLASS="FUNCTION"
 
1035
>pgp_pub_encrypt()</CODE
 
1036
></A
 
1037
></H3
 
1038
><PRE
 
1039
CLASS="SYNOPSIS"
 
1040
>pgp_pub_encrypt(data text, key bytea [, options text ]) returns bytea
 
1041
pgp_pub_encrypt_bytea(data bytea, key bytea [, options text ]) returns bytea</PRE
 
1042
><P
 
1043
>    Encrypt <TT
 
1044
CLASS="PARAMETER"
 
1045
>data</TT
 
1046
> with a public PGP key <TT
 
1047
CLASS="PARAMETER"
 
1048
>key</TT
 
1049
>.
 
1050
    Giving this function a secret key will produce a error.
 
1051
   </P
 
1052
><P
 
1053
>    The <TT
 
1054
CLASS="PARAMETER"
 
1055
>options</TT
 
1056
> parameter can contain option settings,
 
1057
    as described below.
 
1058
   </P
 
1059
></DIV
 
1060
><DIV
 
1061
CLASS="SECT3"
 
1062
><H3
 
1063
CLASS="SECT3"
 
1064
><A
 
1065
NAME="AEN132927"
 
1066
>F.28.3.4. <CODE
 
1067
CLASS="FUNCTION"
 
1068
>pgp_pub_decrypt()</CODE
 
1069
></A
 
1070
></H3
 
1071
><PRE
 
1072
CLASS="SYNOPSIS"
 
1073
>pgp_pub_decrypt(msg bytea, key bytea [, psw text [, options text ]]) returns text
 
1074
pgp_pub_decrypt_bytea(msg bytea, key bytea [, psw text [, options text ]]) returns bytea</PRE
 
1075
><P
 
1076
>    Decrypt a public-key-encrypted message.  <TT
 
1077
CLASS="PARAMETER"
 
1078
>key</TT
 
1079
> must be the
 
1080
    secret key corresponding to the public key that was used to encrypt.
 
1081
    If the secret key is password-protected, you must give the password in
 
1082
    <TT
 
1083
CLASS="PARAMETER"
 
1084
>psw</TT
 
1085
>.  If there is no password, but you want to specify
 
1086
    options, you need to give an empty password.
 
1087
   </P
 
1088
><P
 
1089
>    Decrypting <TT
 
1090
CLASS="TYPE"
 
1091
>bytea</TT
 
1092
> data with <CODE
 
1093
CLASS="FUNCTION"
 
1094
>pgp_pub_decrypt</CODE
 
1095
> is disallowed.
 
1096
    This is to avoid outputting invalid character data.  Decrypting
 
1097
    originally textual data with <CODE
 
1098
CLASS="FUNCTION"
 
1099
>pgp_pub_decrypt_bytea</CODE
 
1100
> is fine.
 
1101
   </P
 
1102
><P
 
1103
>    The <TT
 
1104
CLASS="PARAMETER"
 
1105
>options</TT
 
1106
> parameter can contain option settings,
 
1107
    as described below.
 
1108
   </P
 
1109
></DIV
 
1110
><DIV
 
1111
CLASS="SECT3"
 
1112
><H3
 
1113
CLASS="SECT3"
 
1114
><A
 
1115
NAME="AEN132940"
 
1116
>F.28.3.5. <CODE
 
1117
CLASS="FUNCTION"
 
1118
>pgp_key_id()</CODE
 
1119
></A
 
1120
></H3
 
1121
><PRE
 
1122
CLASS="SYNOPSIS"
 
1123
>pgp_key_id(bytea) returns text</PRE
 
1124
><P
 
1125
>    <CODE
 
1126
CLASS="FUNCTION"
 
1127
>pgp_key_id</CODE
 
1128
> extracts the key ID of a PGP public or secret key.
 
1129
    Or it gives the key ID that was used for encrypting the data, if given
 
1130
    an encrypted message.
 
1131
   </P
 
1132
><P
 
1133
>    It can return 2 special key IDs:
 
1134
   </P
 
1135
><P
 
1136
></P
 
1137
><UL
 
1138
><LI
 
1139
><P
 
1140
>      <TT
 
1141
CLASS="LITERAL"
 
1142
>SYMKEY</TT
 
1143
>
 
1144
     </P
 
1145
><P
 
1146
>      The message is encrypted with a symmetric key.
 
1147
     </P
 
1148
></LI
 
1149
><LI
 
1150
><P
 
1151
>      <TT
 
1152
CLASS="LITERAL"
 
1153
>ANYKEY</TT
 
1154
>
 
1155
     </P
 
1156
><P
 
1157
>      The message is public-key encrypted, but the key ID has been removed.
 
1158
      That means you will need to try all your secret keys on it to see
 
1159
      which one decrypts it.  <TT
 
1160
CLASS="FILENAME"
 
1161
>pgcrypto</TT
 
1162
> itself does not produce
 
1163
      such messages.
 
1164
     </P
 
1165
></LI
 
1166
></UL
 
1167
><P
 
1168
>    Note that different keys may have the same ID.   This is rare but a normal
 
1169
    event. The client application should then try to decrypt with each one,
 
1170
    to see which fits &mdash; like handling <TT
 
1171
CLASS="LITERAL"
 
1172
>ANYKEY</TT
 
1173
>.
 
1174
   </P
 
1175
></DIV
 
1176
><DIV
 
1177
CLASS="SECT3"
 
1178
><H3
 
1179
CLASS="SECT3"
 
1180
><A
 
1181
NAME="AEN132959"
 
1182
>F.28.3.6. <CODE
 
1183
CLASS="FUNCTION"
 
1184
>armor()</CODE
 
1185
>, <CODE
 
1186
CLASS="FUNCTION"
 
1187
>dearmor()</CODE
 
1188
></A
 
1189
></H3
 
1190
><PRE
 
1191
CLASS="SYNOPSIS"
 
1192
>armor(data bytea) returns text
 
1193
dearmor(data text) returns bytea</PRE
 
1194
><P
 
1195
>    These functions wrap/unwrap binary data into PGP ASCII-armor format,
 
1196
    which is basically Base64 with CRC and additional formatting.
 
1197
   </P
 
1198
></DIV
 
1199
><DIV
 
1200
CLASS="SECT3"
 
1201
><H3
 
1202
CLASS="SECT3"
 
1203
><A
 
1204
NAME="AEN132965"
 
1205
>F.28.3.7. Options for PGP Functions</A
 
1206
></H3
 
1207
><P
 
1208
>    Options are named to be similar to GnuPG.  An option's value should be
 
1209
    given after an equal sign; separate options from each other with commas.
 
1210
    For example:
 
1211
</P><PRE
 
1212
CLASS="PROGRAMLISTING"
 
1213
>pgp_sym_encrypt(data, psw, 'compress-algo=1, cipher-algo=aes256')</PRE
 
1214
><P>
 
1215
   </P
 
1216
><P
 
1217
>    All of the options except <TT
 
1218
CLASS="LITERAL"
 
1219
>convert-crlf</TT
 
1220
> apply only to
 
1221
    encrypt functions.  Decrypt functions get the parameters from the PGP
 
1222
    data.
 
1223
   </P
 
1224
><P
 
1225
>    The most interesting options are probably
 
1226
    <TT
 
1227
CLASS="LITERAL"
 
1228
>compress-algo</TT
 
1229
> and <TT
 
1230
CLASS="LITERAL"
 
1231
>unicode-mode</TT
 
1232
>.
 
1233
    The rest should have reasonable defaults.
 
1234
   </P
 
1235
><DIV
 
1236
CLASS="SECT4"
 
1237
><H4
 
1238
CLASS="SECT4"
 
1239
><A
 
1240
NAME="AEN132974"
 
1241
>F.28.3.7.1. cipher-algo</A
 
1242
></H4
 
1243
><P
 
1244
>    Which cipher algorithm to use.
 
1245
   </P
 
1246
><P
 
1247
CLASS="LITERALLAYOUT"
 
1248
>Values:&nbsp;bf,&nbsp;aes128,&nbsp;aes192,&nbsp;aes256&nbsp;(OpenSSL-only:&nbsp;<TT
 
1249
CLASS="LITERAL"
 
1250
>3des</TT
 
1251
>,&nbsp;<TT
 
1252
CLASS="LITERAL"
 
1253
>cast5</TT
 
1254
>)<br>
 
1255
Default:&nbsp;aes128<br>
 
1256
Applies&nbsp;to:&nbsp;pgp_sym_encrypt,&nbsp;pgp_pub_encrypt</P
 
1257
></DIV
 
1258
><DIV
 
1259
CLASS="SECT4"
 
1260
><H4
 
1261
CLASS="SECT4"
 
1262
><A
 
1263
NAME="AEN132980"
 
1264
>F.28.3.7.2. compress-algo</A
 
1265
></H4
 
1266
><P
 
1267
>    Which compression algorithm to use.  Only available if
 
1268
    <SPAN
 
1269
CLASS="PRODUCTNAME"
 
1270
>PostgreSQL</SPAN
 
1271
> was built with zlib.
 
1272
   </P
 
1273
><P
 
1274
CLASS="LITERALLAYOUT"
 
1275
>Values:<br>
 
1276
&nbsp;&nbsp;0&nbsp;-&nbsp;no&nbsp;compression<br>
 
1277
&nbsp;&nbsp;1&nbsp;-&nbsp;ZIP&nbsp;compression<br>
 
1278
&nbsp;&nbsp;2&nbsp;-&nbsp;ZLIB&nbsp;compression&nbsp;(=&nbsp;ZIP&nbsp;plus&nbsp;meta-data&nbsp;and&nbsp;block&nbsp;CRCs)<br>
 
1279
Default:&nbsp;0<br>
 
1280
Applies&nbsp;to:&nbsp;pgp_sym_encrypt,&nbsp;pgp_pub_encrypt</P
 
1281
></DIV
 
1282
><DIV
 
1283
CLASS="SECT4"
 
1284
><H4
 
1285
CLASS="SECT4"
 
1286
><A
 
1287
NAME="AEN132985"
 
1288
>F.28.3.7.3. compress-level</A
 
1289
></H4
 
1290
><P
 
1291
>    How much to compress.  Higher levels compress smaller but are slower.
 
1292
    0 disables compression.
 
1293
   </P
 
1294
><P
 
1295
CLASS="LITERALLAYOUT"
 
1296
>Values:&nbsp;0,&nbsp;1-9<br>
 
1297
Default:&nbsp;6<br>
 
1298
Applies&nbsp;to:&nbsp;pgp_sym_encrypt,&nbsp;pgp_pub_encrypt</P
 
1299
></DIV
 
1300
><DIV
 
1301
CLASS="SECT4"
 
1302
><H4
 
1303
CLASS="SECT4"
 
1304
><A
 
1305
NAME="AEN132989"
 
1306
>F.28.3.7.4. convert-crlf</A
 
1307
></H4
 
1308
><P
 
1309
>    Whether to convert <TT
 
1310
CLASS="LITERAL"
 
1311
>\n</TT
 
1312
> into <TT
 
1313
CLASS="LITERAL"
 
1314
>\r\n</TT
 
1315
> when
 
1316
    encrypting and <TT
 
1317
CLASS="LITERAL"
 
1318
>\r\n</TT
 
1319
> to <TT
 
1320
CLASS="LITERAL"
 
1321
>\n</TT
 
1322
> when
 
1323
    decrypting.  RFC 4880 specifies that text data should be stored using
 
1324
    <TT
 
1325
CLASS="LITERAL"
 
1326
>\r\n</TT
 
1327
> line-feeds.  Use this to get fully RFC-compliant
 
1328
    behavior.
 
1329
   </P
 
1330
><P
 
1331
CLASS="LITERALLAYOUT"
 
1332
>Values:&nbsp;0,&nbsp;1<br>
 
1333
Default:&nbsp;0<br>
 
1334
Applies&nbsp;to:&nbsp;pgp_sym_encrypt,&nbsp;pgp_pub_encrypt,&nbsp;pgp_sym_decrypt,&nbsp;pgp_pub_decrypt</P
 
1335
></DIV
 
1336
><DIV
 
1337
CLASS="SECT4"
 
1338
><H4
 
1339
CLASS="SECT4"
 
1340
><A
 
1341
NAME="AEN132998"
 
1342
>F.28.3.7.5. disable-mdc</A
 
1343
></H4
 
1344
><P
 
1345
>    Do not protect data with SHA-1.  The only good reason to use this
 
1346
    option is to achieve compatibility with ancient PGP products, predating
 
1347
    the addition of SHA-1 protected packets to RFC 4880.
 
1348
    Recent gnupg.org and pgp.com software supports it fine.
 
1349
   </P
 
1350
><P
 
1351
CLASS="LITERALLAYOUT"
 
1352
>Values:&nbsp;0,&nbsp;1<br>
 
1353
Default:&nbsp;0<br>
 
1354
Applies&nbsp;to:&nbsp;pgp_sym_encrypt,&nbsp;pgp_pub_encrypt</P
 
1355
></DIV
 
1356
><DIV
 
1357
CLASS="SECT4"
 
1358
><H4
 
1359
CLASS="SECT4"
 
1360
><A
 
1361
NAME="AEN133002"
 
1362
>F.28.3.7.6. enable-session-key</A
 
1363
></H4
 
1364
><P
 
1365
>    Use separate session key.  Public-key encryption always uses a separate
 
1366
    session key; this is for symmetric-key encryption, which by default
 
1367
    uses the S2K key directly.
 
1368
   </P
 
1369
><P
 
1370
CLASS="LITERALLAYOUT"
 
1371
>Values:&nbsp;0,&nbsp;1<br>
 
1372
Default:&nbsp;0<br>
 
1373
Applies&nbsp;to:&nbsp;pgp_sym_encrypt</P
 
1374
></DIV
 
1375
><DIV
 
1376
CLASS="SECT4"
 
1377
><H4
 
1378
CLASS="SECT4"
 
1379
><A
 
1380
NAME="AEN133006"
 
1381
>F.28.3.7.7. s2k-mode</A
 
1382
></H4
 
1383
><P
 
1384
>    Which S2K algorithm to use.
 
1385
   </P
 
1386
><P
 
1387
CLASS="LITERALLAYOUT"
 
1388
>Values:<br>
 
1389
&nbsp;&nbsp;0&nbsp;-&nbsp;Without&nbsp;salt.&nbsp;&nbsp;Dangerous!<br>
 
1390
&nbsp;&nbsp;1&nbsp;-&nbsp;With&nbsp;salt&nbsp;but&nbsp;with&nbsp;fixed&nbsp;iteration&nbsp;count.<br>
 
1391
&nbsp;&nbsp;3&nbsp;-&nbsp;Variable&nbsp;iteration&nbsp;count.<br>
 
1392
Default:&nbsp;3<br>
 
1393
Applies&nbsp;to:&nbsp;pgp_sym_encrypt</P
 
1394
></DIV
 
1395
><DIV
 
1396
CLASS="SECT4"
 
1397
><H4
 
1398
CLASS="SECT4"
 
1399
><A
 
1400
NAME="AEN133010"
 
1401
>F.28.3.7.8. s2k-digest-algo</A
 
1402
></H4
 
1403
><P
 
1404
>    Which digest algorithm to use in S2K calculation.
 
1405
   </P
 
1406
><P
 
1407
CLASS="LITERALLAYOUT"
 
1408
>Values:&nbsp;md5,&nbsp;sha1<br>
 
1409
Default:&nbsp;sha1<br>
 
1410
Applies&nbsp;to:&nbsp;pgp_sym_encrypt</P
 
1411
></DIV
 
1412
><DIV
 
1413
CLASS="SECT4"
 
1414
><H4
 
1415
CLASS="SECT4"
 
1416
><A
 
1417
NAME="AEN133014"
 
1418
>F.28.3.7.9. s2k-cipher-algo</A
 
1419
></H4
 
1420
><P
 
1421
>    Which cipher to use for encrypting separate session key.
 
1422
   </P
 
1423
><P
 
1424
CLASS="LITERALLAYOUT"
 
1425
>Values:&nbsp;bf,&nbsp;aes,&nbsp;aes128,&nbsp;aes192,&nbsp;aes256<br>
 
1426
Default:&nbsp;use&nbsp;cipher-algo<br>
 
1427
Applies&nbsp;to:&nbsp;pgp_sym_encrypt</P
 
1428
></DIV
 
1429
><DIV
 
1430
CLASS="SECT4"
 
1431
><H4
 
1432
CLASS="SECT4"
 
1433
><A
 
1434
NAME="AEN133018"
 
1435
>F.28.3.7.10. unicode-mode</A
 
1436
></H4
 
1437
><P
 
1438
>    Whether to convert textual data from database internal encoding to
 
1439
    UTF-8 and back.  If your database already is UTF-8, no conversion will
 
1440
    be done, but the message will be tagged as UTF-8.  Without this option
 
1441
    it will not be.
 
1442
   </P
 
1443
><P
 
1444
CLASS="LITERALLAYOUT"
 
1445
>Values:&nbsp;0,&nbsp;1<br>
 
1446
Default:&nbsp;0<br>
 
1447
Applies&nbsp;to:&nbsp;pgp_sym_encrypt,&nbsp;pgp_pub_encrypt</P
 
1448
></DIV
 
1449
></DIV
 
1450
><DIV
 
1451
CLASS="SECT3"
 
1452
><H3
 
1453
CLASS="SECT3"
 
1454
><A
 
1455
NAME="AEN133022"
 
1456
>F.28.3.8. Generating PGP Keys with GnuPG</A
 
1457
></H3
 
1458
><P
 
1459
>   To generate a new key:
 
1460
</P><PRE
 
1461
CLASS="PROGRAMLISTING"
 
1462
>gpg --gen-key</PRE
 
1463
><P>
 
1464
  </P
 
1465
><P
 
1466
>   The preferred key type is <SPAN
 
1467
CLASS="QUOTE"
 
1468
>"DSA and Elgamal"</SPAN
 
1469
>.
 
1470
  </P
 
1471
><P
 
1472
>   For RSA encryption you must create either DSA or RSA sign-only key
 
1473
   as master and then add an RSA encryption subkey with
 
1474
   <TT
 
1475
CLASS="LITERAL"
 
1476
>gpg --edit-key</TT
 
1477
>.
 
1478
  </P
 
1479
><P
 
1480
>   To list keys:
 
1481
</P><PRE
 
1482
CLASS="PROGRAMLISTING"
 
1483
>gpg --list-secret-keys</PRE
 
1484
><P>
 
1485
  </P
 
1486
><P
 
1487
>   To export a public key in ASCII-armor format:
 
1488
</P><PRE
 
1489
CLASS="PROGRAMLISTING"
 
1490
>gpg -a --export KEYID &#62; public.key</PRE
 
1491
><P>
 
1492
  </P
 
1493
><P
 
1494
>   To export a secret key in ASCII-armor format:
 
1495
</P><PRE
 
1496
CLASS="PROGRAMLISTING"
 
1497
>gpg -a --export-secret-keys KEYID &#62; secret.key</PRE
 
1498
><P>
 
1499
  </P
 
1500
><P
 
1501
>   You need to use <CODE
 
1502
CLASS="FUNCTION"
 
1503
>dearmor()</CODE
 
1504
> on these keys before giving them to
 
1505
   the PGP functions.  Or if you can handle binary data, you can drop
 
1506
   <TT
 
1507
CLASS="LITERAL"
 
1508
>-a</TT
 
1509
> from the command.
 
1510
  </P
 
1511
><P
 
1512
>   For more details see <TT
 
1513
CLASS="LITERAL"
 
1514
>man gpg</TT
 
1515
>,
 
1516
   <A
 
1517
HREF="http://www.gnupg.org/gph/en/manual.html"
 
1518
TARGET="_top"
 
1519
>The GNU
 
1520
   Privacy Handbook</A
 
1521
> and other documentation on
 
1522
   <A
 
1523
HREF="http://www.gnupg.org"
 
1524
TARGET="_top"
 
1525
>http://www.gnupg.org</A
 
1526
>.
 
1527
  </P
 
1528
></DIV
 
1529
><DIV
 
1530
CLASS="SECT3"
 
1531
><H3
 
1532
CLASS="SECT3"
 
1533
><A
 
1534
NAME="AEN133043"
 
1535
>F.28.3.9. Limitations of PGP Code</A
 
1536
></H3
 
1537
><P
 
1538
></P
 
1539
><UL
 
1540
><LI
 
1541
><P
 
1542
>    No support for signing.  That also means that it is not checked
 
1543
    whether the encryption subkey belongs to the master key.
 
1544
    </P
 
1545
></LI
 
1546
><LI
 
1547
><P
 
1548
>    No support for encryption key as master key.  As such practice
 
1549
    is generally discouraged, this should not be a problem.
 
1550
    </P
 
1551
></LI
 
1552
><LI
 
1553
><P
 
1554
>    No support for several subkeys.  This may seem like a problem, as this
 
1555
    is common practice.  On the other hand, you should not use your regular
 
1556
    GPG/PGP keys with <TT
 
1557
CLASS="FILENAME"
 
1558
>pgcrypto</TT
 
1559
>, but create new ones,
 
1560
    as the usage scenario is rather different.
 
1561
    </P
 
1562
></LI
 
1563
></UL
 
1564
></DIV
 
1565
></DIV
 
1566
><DIV
 
1567
CLASS="SECT2"
 
1568
><H2
 
1569
CLASS="SECT2"
 
1570
><A
 
1571
NAME="AEN133053"
 
1572
>F.28.4. Raw Encryption Functions</A
 
1573
></H2
 
1574
><P
 
1575
>   These functions only run a cipher over data; they don't have any advanced
 
1576
   features of PGP encryption.  Therefore they have some major problems:
 
1577
  </P
 
1578
><P
 
1579
></P
 
1580
><OL
 
1581
TYPE="1"
 
1582
><LI
 
1583
><P
 
1584
>    They use user key directly as cipher key.
 
1585
    </P
 
1586
></LI
 
1587
><LI
 
1588
><P
 
1589
>    They don't provide any integrity checking, to see
 
1590
    if the encrypted data was modified.
 
1591
    </P
 
1592
></LI
 
1593
><LI
 
1594
><P
 
1595
>    They expect that users manage all encryption parameters
 
1596
    themselves, even IV.
 
1597
    </P
 
1598
></LI
 
1599
><LI
 
1600
><P
 
1601
>    They don't handle text.
 
1602
    </P
 
1603
></LI
 
1604
></OL
 
1605
><P
 
1606
>   So, with the introduction of PGP encryption, usage of raw
 
1607
   encryption functions is discouraged.
 
1608
  </P
 
1609
><PRE
 
1610
CLASS="SYNOPSIS"
 
1611
>encrypt(data bytea, key bytea, type text) returns bytea
 
1612
decrypt(data bytea, key bytea, type text) returns bytea
 
1613
 
 
1614
encrypt_iv(data bytea, key bytea, iv bytea, type text) returns bytea
 
1615
decrypt_iv(data bytea, key bytea, iv bytea, type text) returns bytea</PRE
 
1616
><P
 
1617
>   Encrypt/decrypt data using the cipher method specified by
 
1618
   <TT
 
1619
CLASS="PARAMETER"
 
1620
>type</TT
 
1621
>.  The syntax of the
 
1622
   <TT
 
1623
CLASS="PARAMETER"
 
1624
>type</TT
 
1625
> string is:
 
1626
 
 
1627
</P><PRE
 
1628
CLASS="SYNOPSIS"
 
1629
><TT
 
1630
CLASS="REPLACEABLE"
 
1631
><I
 
1632
>algorithm</I
 
1633
></TT
 
1634
> [<SPAN
 
1635
CLASS="OPTIONAL"
 
1636
> <TT
 
1637
CLASS="LITERAL"
 
1638
>-</TT
 
1639
> <TT
 
1640
CLASS="REPLACEABLE"
 
1641
><I
 
1642
>mode</I
 
1643
></TT
 
1644
> </SPAN
 
1645
>] [<SPAN
 
1646
CLASS="OPTIONAL"
 
1647
> <TT
 
1648
CLASS="LITERAL"
 
1649
>/pad:</TT
 
1650
> <TT
 
1651
CLASS="REPLACEABLE"
 
1652
><I
 
1653
>padding</I
 
1654
></TT
 
1655
> </SPAN
 
1656
>]</PRE
 
1657
><P>
 
1658
   where <TT
 
1659
CLASS="REPLACEABLE"
 
1660
><I
 
1661
>algorithm</I
 
1662
></TT
 
1663
> is one of:
 
1664
 
 
1665
  <P
 
1666
></P
 
1667
></P><UL
 
1668
><LI
 
1669
><P
 
1670
><TT
 
1671
CLASS="LITERAL"
 
1672
>bf</TT
 
1673
> &mdash; Blowfish</P
 
1674
></LI
 
1675
><LI
 
1676
><P
 
1677
><TT
 
1678
CLASS="LITERAL"
 
1679
>aes</TT
 
1680
> &mdash; AES (Rijndael-128)</P
 
1681
></LI
 
1682
></UL
 
1683
><P>
 
1684
   and <TT
 
1685
CLASS="REPLACEABLE"
 
1686
><I
 
1687
>mode</I
 
1688
></TT
 
1689
> is one of:
 
1690
  <P
 
1691
></P
 
1692
></P><UL
 
1693
><LI
 
1694
><P
 
1695
>    <TT
 
1696
CLASS="LITERAL"
 
1697
>cbc</TT
 
1698
> &mdash; next block depends on previous (default)
 
1699
    </P
 
1700
></LI
 
1701
><LI
 
1702
><P
 
1703
>    <TT
 
1704
CLASS="LITERAL"
 
1705
>ecb</TT
 
1706
> &mdash; each block is encrypted separately (for
 
1707
    testing only)
 
1708
    </P
 
1709
></LI
 
1710
></UL
 
1711
><P>
 
1712
   and <TT
 
1713
CLASS="REPLACEABLE"
 
1714
><I
 
1715
>padding</I
 
1716
></TT
 
1717
> is one of:
 
1718
  <P
 
1719
></P
 
1720
></P><UL
 
1721
><LI
 
1722
><P
 
1723
>    <TT
 
1724
CLASS="LITERAL"
 
1725
>pkcs</TT
 
1726
> &mdash; data may be any length (default)
 
1727
    </P
 
1728
></LI
 
1729
><LI
 
1730
><P
 
1731
>    <TT
 
1732
CLASS="LITERAL"
 
1733
>none</TT
 
1734
> &mdash; data must be multiple of cipher block size
 
1735
    </P
 
1736
></LI
 
1737
></UL
 
1738
><P>
 
1739
  </P
 
1740
><P
 
1741
>   So, for example, these are equivalent:
 
1742
</P><PRE
 
1743
CLASS="PROGRAMLISTING"
 
1744
>encrypt(data, 'fooz', 'bf')
 
1745
encrypt(data, 'fooz', 'bf-cbc/pad:pkcs')</PRE
 
1746
><P>
 
1747
  </P
 
1748
><P
 
1749
>   In <CODE
 
1750
CLASS="FUNCTION"
 
1751
>encrypt_iv</CODE
 
1752
> and <CODE
 
1753
CLASS="FUNCTION"
 
1754
>decrypt_iv</CODE
 
1755
>, the
 
1756
   <TT
 
1757
CLASS="PARAMETER"
 
1758
>iv</TT
 
1759
> parameter is the initial value for the CBC mode;
 
1760
   it is ignored for ECB.
 
1761
   It is clipped or padded with zeroes if not exactly block size.
 
1762
   It defaults to all zeroes in the functions without this parameter.
 
1763
  </P
 
1764
></DIV
 
1765
><DIV
 
1766
CLASS="SECT2"
 
1767
><H2
 
1768
CLASS="SECT2"
 
1769
><A
 
1770
NAME="AEN133108"
 
1771
>F.28.5. Random-Data Functions</A
 
1772
></H2
 
1773
><PRE
 
1774
CLASS="SYNOPSIS"
 
1775
>gen_random_bytes(count integer) returns bytea</PRE
 
1776
><P
 
1777
>   Returns <TT
 
1778
CLASS="PARAMETER"
 
1779
>count</TT
 
1780
> cryptographically strong random bytes.
 
1781
   At most 1024 bytes can be extracted at a time.  This is to avoid
 
1782
   draining the randomness generator pool.
 
1783
  </P
 
1784
></DIV
 
1785
><DIV
 
1786
CLASS="SECT2"
 
1787
><H2
 
1788
CLASS="SECT2"
 
1789
><A
 
1790
NAME="AEN133113"
 
1791
>F.28.6. Notes</A
 
1792
></H2
 
1793
><DIV
 
1794
CLASS="SECT3"
 
1795
><H3
 
1796
CLASS="SECT3"
 
1797
><A
 
1798
NAME="AEN133115"
 
1799
>F.28.6.1. Configuration</A
 
1800
></H3
 
1801
><P
 
1802
>    <TT
 
1803
CLASS="FILENAME"
 
1804
>pgcrypto</TT
 
1805
> configures itself according to the findings of the
 
1806
    main PostgreSQL <TT
 
1807
CLASS="LITERAL"
 
1808
>configure</TT
 
1809
> script.  The options that
 
1810
    affect it are <TT
 
1811
CLASS="LITERAL"
 
1812
>--with-zlib</TT
 
1813
> and
 
1814
    <TT
 
1815
CLASS="LITERAL"
 
1816
>--with-openssl</TT
 
1817
>.
 
1818
   </P
 
1819
><P
 
1820
>    When compiled with zlib, PGP encryption functions are able to
 
1821
    compress data before encrypting.
 
1822
   </P
 
1823
><P
 
1824
>    When compiled with OpenSSL, there will be more algorithms available.
 
1825
    Also public-key encryption functions will be faster as OpenSSL
 
1826
    has more optimized BIGNUM functions.
 
1827
   </P
 
1828
><DIV
 
1829
CLASS="TABLE"
 
1830
><A
 
1831
NAME="PGCRYPTO-WITH-WITHOUT-OPENSSL"
 
1832
></A
 
1833
><P
 
1834
><B
 
1835
>Table F-18. Summary of Functionality with and without OpenSSL</B
 
1836
></P
 
1837
><TABLE
 
1838
BORDER="1"
 
1839
CLASS="CALSTABLE"
 
1840
><COL><COL><COL><THEAD
 
1841
><TR
 
1842
><TH
 
1843
>Functionality</TH
 
1844
><TH
 
1845
>Built-in</TH
 
1846
><TH
 
1847
>With OpenSSL</TH
 
1848
></TR
 
1849
></THEAD
 
1850
><TBODY
 
1851
><TR
 
1852
><TD
 
1853
>MD5</TD
 
1854
><TD
 
1855
>yes</TD
 
1856
><TD
 
1857
>yes</TD
 
1858
></TR
 
1859
><TR
 
1860
><TD
 
1861
>SHA1</TD
 
1862
><TD
 
1863
>yes</TD
 
1864
><TD
 
1865
>yes</TD
 
1866
></TR
 
1867
><TR
 
1868
><TD
 
1869
>SHA224/256/384/512</TD
 
1870
><TD
 
1871
>yes</TD
 
1872
><TD
 
1873
>yes (Note 1)</TD
 
1874
></TR
 
1875
><TR
 
1876
><TD
 
1877
>Other digest algorithms</TD
 
1878
><TD
 
1879
>no</TD
 
1880
><TD
 
1881
>yes (Note 2)</TD
 
1882
></TR
 
1883
><TR
 
1884
><TD
 
1885
>Blowfish</TD
 
1886
><TD
 
1887
>yes</TD
 
1888
><TD
 
1889
>yes</TD
 
1890
></TR
 
1891
><TR
 
1892
><TD
 
1893
>AES</TD
 
1894
><TD
 
1895
>yes</TD
 
1896
><TD
 
1897
>yes (Note 3)</TD
 
1898
></TR
 
1899
><TR
 
1900
><TD
 
1901
>DES/3DES/CAST5</TD
 
1902
><TD
 
1903
>no</TD
 
1904
><TD
 
1905
>yes</TD
 
1906
></TR
 
1907
><TR
 
1908
><TD
 
1909
>Raw encryption</TD
 
1910
><TD
 
1911
>yes</TD
 
1912
><TD
 
1913
>yes</TD
 
1914
></TR
 
1915
><TR
 
1916
><TD
 
1917
>PGP Symmetric encryption</TD
 
1918
><TD
 
1919
>yes</TD
 
1920
><TD
 
1921
>yes</TD
 
1922
></TR
 
1923
><TR
 
1924
><TD
 
1925
>PGP Public-Key encryption</TD
 
1926
><TD
 
1927
>yes</TD
 
1928
><TD
 
1929
>yes</TD
 
1930
></TR
 
1931
></TBODY
 
1932
></TABLE
 
1933
></DIV
 
1934
><P
 
1935
>    Notes:
 
1936
   </P
 
1937
><P
 
1938
></P
 
1939
><OL
 
1940
TYPE="1"
 
1941
><LI
 
1942
><P
 
1943
>      SHA2 algorithms were added to OpenSSL in version 0.9.8.  For
 
1944
      older versions, <TT
 
1945
CLASS="FILENAME"
 
1946
>pgcrypto</TT
 
1947
> will use built-in code.
 
1948
     </P
 
1949
></LI
 
1950
><LI
 
1951
><P
 
1952
>      Any digest algorithm OpenSSL supports is automatically picked up.
 
1953
      This is not possible with ciphers, which need to be supported
 
1954
      explicitly.
 
1955
     </P
 
1956
></LI
 
1957
><LI
 
1958
><P
 
1959
>      AES is included in OpenSSL since version 0.9.7.  For
 
1960
      older versions, <TT
 
1961
CLASS="FILENAME"
 
1962
>pgcrypto</TT
 
1963
> will use built-in code.
 
1964
     </P
 
1965
></LI
 
1966
></OL
 
1967
></DIV
 
1968
><DIV
 
1969
CLASS="SECT3"
 
1970
><H3
 
1971
CLASS="SECT3"
 
1972
><A
 
1973
NAME="AEN133183"
 
1974
>F.28.6.2. NULL Handling</A
 
1975
></H3
 
1976
><P
 
1977
>    As is standard in SQL, all functions return NULL, if any of the arguments
 
1978
    are NULL.  This may create security risks on careless usage.
 
1979
   </P
 
1980
></DIV
 
1981
><DIV
 
1982
CLASS="SECT3"
 
1983
><H3
 
1984
CLASS="SECT3"
 
1985
><A
 
1986
NAME="AEN133186"
 
1987
>F.28.6.3. Security Limitations</A
 
1988
></H3
 
1989
><P
 
1990
>    All <TT
 
1991
CLASS="FILENAME"
 
1992
>pgcrypto</TT
 
1993
> functions run inside the database server.
 
1994
    That means that all
 
1995
    the data and passwords move between <TT
 
1996
CLASS="FILENAME"
 
1997
>pgcrypto</TT
 
1998
> and client
 
1999
    applications in clear text.  Thus you must:
 
2000
   </P
 
2001
><P
 
2002
></P
 
2003
><OL
 
2004
TYPE="1"
 
2005
><LI
 
2006
><P
 
2007
>Connect locally or use SSL connections.</P
 
2008
></LI
 
2009
><LI
 
2010
><P
 
2011
>Trust both system and database administrator.</P
 
2012
></LI
 
2013
></OL
 
2014
><P
 
2015
>    If you cannot, then better do crypto inside client application.
 
2016
   </P
 
2017
></DIV
 
2018
><DIV
 
2019
CLASS="SECT3"
 
2020
><H3
 
2021
CLASS="SECT3"
 
2022
><A
 
2023
NAME="AEN133197"
 
2024
>F.28.6.4. Useful Reading</A
 
2025
></H3
 
2026
><P
 
2027
></P
 
2028
><UL
 
2029
><LI
 
2030
><P
 
2031
><A
 
2032
HREF="http://www.gnupg.org/gph/en/manual.html"
 
2033
TARGET="_top"
 
2034
>http://www.gnupg.org/gph/en/manual.html</A
 
2035
></P
 
2036
><P
 
2037
>The GNU Privacy Handbook.</P
 
2038
></LI
 
2039
><LI
 
2040
><P
 
2041
><A
 
2042
HREF="http://www.openwall.com/crypt/"
 
2043
TARGET="_top"
 
2044
>http://www.openwall.com/crypt/</A
 
2045
></P
 
2046
><P
 
2047
>Describes the crypt-blowfish algorithm.</P
 
2048
></LI
 
2049
><LI
 
2050
><P
 
2051
>      <A
 
2052
HREF="http://www.stack.nl/~galactus/remailers/passphrase-faq.html"
 
2053
TARGET="_top"
 
2054
>http://www.stack.nl/~galactus/remailers/passphrase-faq.html</A
 
2055
>
 
2056
     </P
 
2057
><P
 
2058
>How to choose a good password.</P
 
2059
></LI
 
2060
><LI
 
2061
><P
 
2062
><A
 
2063
HREF="http://world.std.com/~reinhold/diceware.html"
 
2064
TARGET="_top"
 
2065
>http://world.std.com/~reinhold/diceware.html</A
 
2066
></P
 
2067
><P
 
2068
>Interesting idea for picking passwords.</P
 
2069
></LI
 
2070
><LI
 
2071
><P
 
2072
>      <A
 
2073
HREF="http://www.interhack.net/people/cmcurtin/snake-oil-faq.html"
 
2074
TARGET="_top"
 
2075
>http://www.interhack.net/people/cmcurtin/snake-oil-faq.html</A
 
2076
>
 
2077
     </P
 
2078
><P
 
2079
>Describes good and bad cryptography.</P
 
2080
></LI
 
2081
></UL
 
2082
></DIV
 
2083
><DIV
 
2084
CLASS="SECT3"
 
2085
><H3
 
2086
CLASS="SECT3"
 
2087
><A
 
2088
NAME="AEN133220"
 
2089
>F.28.6.5. Technical References</A
 
2090
></H3
 
2091
><P
 
2092
></P
 
2093
><UL
 
2094
><LI
 
2095
><P
 
2096
><A
 
2097
HREF="http://www.ietf.org/rfc/rfc4880.txt"
 
2098
TARGET="_top"
 
2099
>http://www.ietf.org/rfc/rfc4880.txt</A
 
2100
></P
 
2101
><P
 
2102
>OpenPGP message format.</P
 
2103
></LI
 
2104
><LI
 
2105
><P
 
2106
><A
 
2107
HREF="http://www.ietf.org/rfc/rfc1321.txt"
 
2108
TARGET="_top"
 
2109
>http://www.ietf.org/rfc/rfc1321.txt</A
 
2110
></P
 
2111
><P
 
2112
>The MD5 Message-Digest Algorithm.</P
 
2113
></LI
 
2114
><LI
 
2115
><P
 
2116
><A
 
2117
HREF="http://www.ietf.org/rfc/rfc2104.txt"
 
2118
TARGET="_top"
 
2119
>http://www.ietf.org/rfc/rfc2104.txt</A
 
2120
></P
 
2121
><P
 
2122
>HMAC: Keyed-Hashing for Message Authentication.</P
 
2123
></LI
 
2124
><LI
 
2125
><P
 
2126
>      <A
 
2127
HREF="http://www.usenix.org/events/usenix99/provos.html"
 
2128
TARGET="_top"
 
2129
>http://www.usenix.org/events/usenix99/provos.html</A
 
2130
>
 
2131
     </P
 
2132
><P
 
2133
>Comparison of crypt-des, crypt-md5 and bcrypt algorithms.</P
 
2134
></LI
 
2135
><LI
 
2136
><P
 
2137
><A
 
2138
HREF="http://csrc.nist.gov/cryptval/des.htm"
 
2139
TARGET="_top"
 
2140
>http://csrc.nist.gov/cryptval/des.htm</A
 
2141
></P
 
2142
><P
 
2143
>Standards for DES, 3DES and AES.</P
 
2144
></LI
 
2145
><LI
 
2146
><P
 
2147
>      <A
 
2148
HREF="http://en.wikipedia.org/wiki/Fortuna_(PRNG)"
 
2149
TARGET="_top"
 
2150
>http://en.wikipedia.org/wiki/Fortuna_(PRNG)</A
 
2151
>
 
2152
     </P
 
2153
><P
 
2154
>Description of Fortuna CSPRNG.</P
 
2155
></LI
 
2156
><LI
 
2157
><P
 
2158
><A
 
2159
HREF="http://jlcooke.ca/random/"
 
2160
TARGET="_top"
 
2161
>http://jlcooke.ca/random/</A
 
2162
></P
 
2163
><P
 
2164
>Jean-Luc Cooke Fortuna-based <TT
 
2165
CLASS="FILENAME"
 
2166
>/dev/random</TT
 
2167
> driver for Linux.</P
 
2168
></LI
 
2169
><LI
 
2170
><P
 
2171
><A
 
2172
HREF="http://research.cyber.ee/~lipmaa/crypto/"
 
2173
TARGET="_top"
 
2174
>http://research.cyber.ee/~lipmaa/crypto/</A
 
2175
></P
 
2176
><P
 
2177
>Collection of cryptology pointers.</P
 
2178
></LI
 
2179
></UL
 
2180
></DIV
 
2181
></DIV
 
2182
><DIV
 
2183
CLASS="SECT2"
 
2184
><H2
 
2185
CLASS="SECT2"
 
2186
><A
 
2187
NAME="AEN133256"
 
2188
>F.28.7. Author</A
 
2189
></H2
 
2190
><P
 
2191
>   Marko Kreen <CODE
 
2192
CLASS="EMAIL"
 
2193
>&#60;<A
 
2194
HREF="mailto:markokr@gmail.com"
 
2195
>markokr@gmail.com</A
 
2196
>&#62;</CODE
 
2197
>
 
2198
  </P
 
2199
><P
 
2200
>   <TT
 
2201
CLASS="FILENAME"
 
2202
>pgcrypto</TT
 
2203
> uses code from the following sources:
 
2204
  </P
 
2205
><DIV
 
2206
CLASS="INFORMALTABLE"
 
2207
><P
 
2208
></P
 
2209
><A
 
2210
NAME="AEN133262"
 
2211
></A
 
2212
><TABLE
 
2213
BORDER="1"
 
2214
CLASS="CALSTABLE"
 
2215
><COL><COL><COL><THEAD
 
2216
><TR
 
2217
><TH
 
2218
>Algorithm</TH
 
2219
><TH
 
2220
>Author</TH
 
2221
><TH
 
2222
>Source origin</TH
 
2223
></TR
 
2224
></THEAD
 
2225
><TBODY
 
2226
><TR
 
2227
><TD
 
2228
>DES crypt</TD
 
2229
><TD
 
2230
>David Burren and others</TD
 
2231
><TD
 
2232
>FreeBSD libcrypt</TD
 
2233
></TR
 
2234
><TR
 
2235
><TD
 
2236
>MD5 crypt</TD
 
2237
><TD
 
2238
>Poul-Henning Kamp</TD
 
2239
><TD
 
2240
>FreeBSD libcrypt</TD
 
2241
></TR
 
2242
><TR
 
2243
><TD
 
2244
>Blowfish crypt</TD
 
2245
><TD
 
2246
>Solar Designer</TD
 
2247
><TD
 
2248
>www.openwall.com</TD
 
2249
></TR
 
2250
><TR
 
2251
><TD
 
2252
>Blowfish cipher</TD
 
2253
><TD
 
2254
>Simon Tatham</TD
 
2255
><TD
 
2256
>PuTTY</TD
 
2257
></TR
 
2258
><TR
 
2259
><TD
 
2260
>Rijndael cipher</TD
 
2261
><TD
 
2262
>Brian Gladman</TD
 
2263
><TD
 
2264
>OpenBSD sys/crypto</TD
 
2265
></TR
 
2266
><TR
 
2267
><TD
 
2268
>MD5 and SHA1</TD
 
2269
><TD
 
2270
>WIDE Project</TD
 
2271
><TD
 
2272
>KAME kame/sys/crypto</TD
 
2273
></TR
 
2274
><TR
 
2275
><TD
 
2276
>SHA256/384/512 </TD
 
2277
><TD
 
2278
>Aaron D. Gifford</TD
 
2279
><TD
 
2280
>OpenBSD sys/crypto</TD
 
2281
></TR
 
2282
><TR
 
2283
><TD
 
2284
>BIGNUM math</TD
 
2285
><TD
 
2286
>Michael J. Fromberger</TD
 
2287
><TD
 
2288
>dartmouth.edu/~sting/sw/imath</TD
 
2289
></TR
 
2290
></TBODY
 
2291
></TABLE
 
2292
><P
 
2293
></P
 
2294
></DIV
 
2295
></DIV
 
2296
></DIV
 
2297
><DIV
 
2298
CLASS="NAVFOOTER"
 
2299
><HR
 
2300
ALIGN="LEFT"
 
2301
WIDTH="100%"><TABLE
 
2302
SUMMARY="Footer navigation table"
 
2303
WIDTH="100%"
 
2304
BORDER="0"
 
2305
CELLPADDING="0"
 
2306
CELLSPACING="0"
 
2307
><TR
 
2308
><TD
 
2309
WIDTH="33%"
 
2310
ALIGN="left"
 
2311
VALIGN="top"
 
2312
><A
 
2313
HREF="pgbuffercache.html"
 
2314
ACCESSKEY="P"
 
2315
>Prev</A
 
2316
></TD
 
2317
><TD
 
2318
WIDTH="34%"
 
2319
ALIGN="center"
 
2320
VALIGN="top"
 
2321
><A
 
2322
HREF="index.html"
 
2323
ACCESSKEY="H"
 
2324
>Home</A
 
2325
></TD
 
2326
><TD
 
2327
WIDTH="33%"
 
2328
ALIGN="right"
 
2329
VALIGN="top"
 
2330
><A
 
2331
HREF="pgfreespacemap.html"
 
2332
ACCESSKEY="N"
 
2333
>Next</A
 
2334
></TD
 
2335
></TR
 
2336
><TR
 
2337
><TD
 
2338
WIDTH="33%"
 
2339
ALIGN="left"
 
2340
VALIGN="top"
 
2341
>pg_buffercache</TD
 
2342
><TD
 
2343
WIDTH="34%"
 
2344
ALIGN="center"
 
2345
VALIGN="top"
 
2346
><A
 
2347
HREF="contrib.html"
 
2348
ACCESSKEY="U"
 
2349
>Up</A
 
2350
></TD
 
2351
><TD
 
2352
WIDTH="33%"
 
2353
ALIGN="right"
 
2354
VALIGN="top"
 
2355
>pg_freespacemap</TD
 
2356
></TR
 
2357
></TABLE
 
2358
></DIV
 
2359
></BODY
 
2360
></HTML
 
2361
>
 
 
b'\\ No newline at end of file'