Training courses

Kernel and Embedded Linux

Bootlin training courses

Embedded Linux, kernel,
Yocto Project, Buildroot, real-time,
graphics, boot time, debugging...

Bootlin logo

Elixir Cross Referencer

  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
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
.\"	$OpenBSD: crypto.9,v 1.25 2003/07/11 13:47:41 jmc Exp $
.\"	$NetBSD: opencrypto.9,v 1.23 2022/05/22 11:40:46 riastradh Exp $
.\"
.\" The author of this man page is Angelos D. Keromytis (angelos@cis.upenn.edu)
.\"
.\" Copyright (c) 2000, 2001 Angelos D. Keromytis
.\"
.\" Permission to use, copy, and modify this software with or without fee
.\" is hereby granted, provided that this entire notice is included in
.\" all source code copies of any software which is or includes a copy or
.\" modification of this software.
.\"
.\" THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR
.\" IMPLIED WARRANTY. IN PARTICULAR, NONE OF THE AUTHORS MAKES ANY
.\" REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE
.\" MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR
.\" PURPOSE.
.\"
.Dd May 26, 2017
.Dt OPENCRYPTO 9
.Os
.Sh NAME
.Nm opencrypto ,
.Nm crypto_get_driverid ,
.Nm crypto_register ,
.Nm crypto_kregister ,
.Nm crypto_unregister ,
.Nm crypto_unregister_all ,
.Nm crypto_done ,
.Nm crypto_kdone ,
.Nm crypto_newsession ,
.Nm crypto_freesession ,
.Nm crypto_dispatch ,
.Nm crypto_kdispatch ,
.Nm crypto_getreq ,
.Nm crypto_freereq
.Nm crypto_kgetreq ,
.Nm crypto_kfreereq
.Nd API for cryptographic services in the kernel
.Sh SYNOPSIS
.In opencrypto/cryptodev.h
.Ft int32_t
.Fn crypto_get_driverid "u_int32_t"
.Ft int
.Fn crypto_register "u_int32_t" "int" "u_int16_t" "u_int32_t" "int (*)(void *, u_int32_t *, struct cryptoini *)" "int (*)(void *, u_int32_t *)" "int (*)(u_int64_t)" "int (*)(struct cryptop *)" "void *"
.Ft int
.Fn crypto_kregister "u_int32_t" "int" "u_int32_t" "int (*)(void *, struct cryptkop *, int)" "void *"
.Ft int
.Fn crypto_unregister "u_int32_t" "int"
.Ft int
.Fn crypto_unregister_all "u_int32_t"
.Ft void
.Fn crypto_done "struct cryptop *"
.Ft void
.Fn crypto_kdone "struct cryptkop *"
.Ft int
.Fn crypto_newsession "u_int64_t *" "struct cryptoini *" "int"
.Ft void
.Fn crypto_freesession "u_int64_t"
.Ft void
.Fn crypto_dispatch "struct cryptop *"
.Ft void
.Fn crypto_kdispatch "struct cryptkop *"
.Ft struct cryptop *
.Fn crypto_getreq "int"
.Ft void
.Fn crypto_freereq "struct cryptop *"
.Ft struct cryptop *
.Fn crypto_kgetreq "int" "int"
.Ft void
.Fn crypto_kfreereq "struct cryptop *"
.Bd -literal

#define EALG_MAX_BLOCK_LEN      16

struct cryptoini {
	int                cri_alg;
	int                cri_klen;
	int                cri_rnd;
	void            *cri_key;
	u_int8_t           cri_iv[EALG_MAX_BLOCK_LEN];
	struct cryptoini  *cri_next;
};

struct cryptodesc {
	int                crd_skip;
	int                crd_len;
	int                crd_inject;
	int                crd_flags;
	struct cryptoini   CRD_INI;
	struct cryptodesc *crd_next;
};

struct cryptop {
	TAILQ_ENTRY(cryptop) crp_next;
	u_int64_t          crp_sid;
	int                crp_ilen;
	int                crp_olen;
	int                crp_etype;
	int                crp_flags;
	void            *crp_buf;
	void            *crp_opaque;
	struct cryptodesc *crp_desc;
	int              (*crp_callback)(struct cryptop *);
	void            *crp_mac;
};

struct crparam {
        void         *crp_p;
        u_int           crp_nbits;
};

#define CRK_MAXPARAM    8

struct cryptkop {
	TAILQ_ENTRY(cryptkop) krp_next;
        u_int              krp_op;         /* i.e. CRK_MOD_EXP or other */
        u_int              krp_status;     /* return status */
        u_short            krp_iparams;    /* # of input parameters */
        u_short            krp_oparams;    /* # of output parameters */
	u_int32_t	   krp_hid;
        struct crparam     krp_param[CRK_MAXPARAM];	  /* kvm */
        int               (*krp_callback)(struct cryptkop *);
};
.Ed
.Sh DESCRIPTION
.Nm
is a framework for drivers of cryptographic hardware to register with
the kernel so
.Dq consumers
(other kernel subsystems, and eventually
users through an appropriate device) are able to make use of it.
Drivers register with the framework the algorithms they support,
and provide entry points (functions) the framework may call to
establish, use, and tear down sessions.
Sessions are used to cache cryptographic information in a particular driver
(or associated hardware), so initialization is not needed with every request.
Consumers of cryptographic services pass a set of
descriptors that instruct the framework (and the drivers registered
with it) of the operations that should be applied on the data (more
than one cryptographic operation can be requested).
.Pp
Keying operations are supported as well.
Unlike the symmetric operators described above,
these sessionless commands perform mathematical operations using
input and output parameters.
.Pp
Since the consumers may not be associated with a process, drivers may
not use condition variables:
.Xr condvar 9 .
The same holds for the framework.
Thus, a callback mechanism is used
to notify a consumer that a request has been completed (the
callback is specified by the consumer on an per-request basis).
The callback is invoked by the framework whether the request was
successfully completed or not.
An error indication is provided in the latter case.
A specific error code,
.Er EAGAIN ,
is used to indicate that a session number has changed and that the
request may be re-submitted immediately with the new session number.
Errors are only returned to the invoking function if not
enough information to call the callback is available (meaning, there
was a fatal error in verifying the arguments).
No callback mechanism is used for session initialization and teardown.
.Pp
The
.Fn crypto_newsession
routine is called by consumers of cryptographic services (such as the
.Xr ipsec 4
stack) that wish to establish a new session with the framework.
On success, the first argument will contain the Session Identifier (SID).
The second argument contains all the necessary information for
the driver to establish the session.
The third argument indicates whether a
hardware driver should be used (1) or not (0).
The various fields in the
.Fa cryptoini
structure are:
.Bl -tag -width foobarmoocow
.It Fa cri_alg
Contains an algorithm identifier.
Currently supported algorithms are:
.Bd -literal
CRYPTO_DES_CBC
CRYPTO_3DES_CBC
CRYPTO_BLF_CBC
CRYPTO_CAST_CBC
CRYPTO_CAMELLIA_CBC
CRYPTO_SKIPJACK_CBC
CRYPTO_ARC4
CRYPTO_AES_CBC
CRYPTO_AES_CTR
CRYPTO_AES_GCM_16
CRYPTO_AES_GMAC
CRYPTO_AES_128_GMAC
CRYPTO_AES_192_GMAC
CRYPTO_AES_256_GMAC
CRYPTO_AES_XCBC_MAC_96
CRYPTO_MD5
CRYPTO_MD5_HMAC
CRYPTO_MD5_HMAC_96
CRYPTO_MD5_KPDK
CRYPTO_NULL_CBC
CRYPTO_NULL_HMAC
CRYPTO_SHA1
CRYPTO_SHA1_HMAC
CRYPTO_SHA1_HMAC_96
CRYPTO_SHA1_KPDK
CRYPTO_SHA2_256_HMAC
CRYPTO_SHA2_384_HMAC
CRYPTO_SHA2_512_HMAC
CRYPTO_RIPEMD160_HMAC
CRYPTO_RIPEMD160_HMAC_96
CRYPTO_DEFLATE_COMP
CRYPTO_DEFLATE_COMP_NOGROW
CRYPTO_GZIP_COMP
.Ed
.Pp
.It Fa cri_klen
Specifies the length of the key in bits, for variable-size key
algorithms.
.It Fa cri_rnd
Specifies the number of rounds to be used with the algorithm, for
variable-round algorithms.
.It Fa cri_key
Contains the key to be used with the algorithm.
.It Fa cri_iv
Contains an explicit initialization vector (IV), if it does not prefix
the data.
This field is ignored during initialization.
If no IV is explicitly passed (see below on details), a random IV is used
by the device driver processing the request.
.It Fa cri_next
Contains a pointer to another
.Fa cryptoini
structure.
Multiple such structures may be linked to establish multi-algorithm sessions
.Pf ( Xr ipsec 4
is an example consumer of such a feature).
.El
.Pp
The
.Fa cryptoini
structure and its contents will not be modified by the framework (or
the drivers used).
Subsequent requests for processing that use the
SID returned will avoid the cost of re-initializing the hardware (in
essence, SID acts as an index in the session cache of the driver).
.Pp
.Fn crypto_freesession
is called with the SID returned by
.Fn crypto_newsession
to disestablish the session.
.Pp
.Fn crypto_dispatch
is called to process a request.
The various fields in the
.Fa cryptop
structure are:
.Bl -tag -width crp_callback
.It Fa crp_sid
Contains the SID.
.It Fa crp_ilen
Indicates the total length in bytes of the buffer to be processed.
.It Fa crp_olen
On return, contains the length of the result, not including
.Fa crd_skip .
For symmetric crypto operations, this will be the same as the input length.
.It Fa crp_alloctype
Indicates the type of buffer, as used in the kernel
.Xr malloc 9
routine.
This will be used if the framework needs to allocate a new
buffer for the result (or for re-formatting the input).
.It Fa crp_callback
This routine is invoked upon completion of the request, whether
successful or not.
It is invoked by the driver through the
.Fn crypto_done
routine.
If the request was not successful, an error code is set in the
.Fa crp_etype
field.
.It Fa crp_etype
Contains the error type, if any errors were encountered, or zero if
the request was successfully processed.
.Pp
Note that this field only makes sense when examined by
the callback routine specified in
.Fa crp_callback .
Errors are returned to the invoker of
.Fn crypto_process
only when enough information is not present to call the callback
routine (i.e., if the pointer passed is
.Dv NULL
or if no callback routine was specified).
.It Fa crp_flags
Is a bitmask of flags associated with this request.
Currently defined flags are:
.Bl -tag -width CRYPTO_F_IMBUF
.It Dv CRYPTO_F_IMBUF
The buffer pointed to by
.Fa crp_buf
is an mbuf chain.
.El
.Pp
.It Fa crp_buf
Points to the input buffer.
On return (when the callback is invoked),
it contains the result of the request.
The input buffer may be an mbuf
chain or a contiguous buffer (of a type identified by
.Fa crp_alloctype ) ,
depending on
.Fa crp_flags .
.It Fa crp_opaque
This is passed through the crypto framework untouched and is
intended for the invoking application's use.
.It Fa crp_desc
This is a linked list of descriptors.
Each descriptor provides
information about what type of cryptographic operation should be done
on the input buffer.
The various fields are:
.Bl -tag -width ".Fa crd_inject"
.It Fa crd_skip
The offset in the input buffer where processing should start.
.It Fa crd_len
How many bytes, after
.Fa crd_skip ,
should be processed.
.It Fa crd_inject
Offset from the beginning of the buffer to insert any results.
For encryption algorithms, this is where the initialization vector
(IV) will be inserted when encrypting or where it can be found when
decrypting (subject to
.Fa crd_flags ) .
For MAC algorithms, this is where the result of the keyed hash will be
inserted.
.It Fa crd_flags
For adjusting general operation from userland,
the following flags are defined:
.Bl -tag -width CRD_F_IV_EXPLICIT
.It Dv CRD_F_ENCRYPT
For encryption algorithms, this bit is set when encryption is required
(when not set, decryption is performed).
.It Dv CRD_F_IV_PRESENT
For encryption algorithms, this bit is set when the IV already
precedes the data, so the
.Fa crd_inject
value will be ignored and no IV will be written in the buffer.
Otherwise, the IV used to encrypt the packet will be written
at the location pointed to by
.Fa crd_inject .
Some applications that do special
.Dq IV cooking ,
such as the half-IV mode in
.Xr ipsec 4 ,
can use this flag to indicate that the IV should not be written on the packet.
This flag is typically used in conjunction with the
.Dv CRD_F_IV_EXPLICIT
flag.
.It Dv CRD_F_IV_EXPLICIT
For encryption algorithms, this bit is set when the IV is explicitly
provided by the consumer in the
.Fa crd_iv
fields.
Otherwise, for encryption operations the IV is provided for by
the driver used to perform the operation, whereas for decryption
operations it is pointed to by the
.Fa crd_inject
field.
This flag is typically used when the IV is calculated
.Dq on the fly
by the consumer, and does not precede the data (some
.Xr ipsec 4
configurations, and the encrypted swap are two such examples).
.It Dv CRD_F_COMP
For compression algorithms, this bit is set when compression is required (when
not set, decompression is performed).
.El
.It Fa CRD_INI
This
.Fa cryptoini
structure will not be modified by the framework or the device drivers.
Since this information accompanies every cryptographic
operation request, drivers may re-initialize state on-demand
(typically an expensive operation).
Furthermore, the cryptographic
framework may re-route requests as a result of full queues or hardware
failure, as described above.
.It Fa crd_next
Point to the next descriptor.
Linked operations are useful in protocols such as
.Xr ipsec 4 ,
where multiple cryptographic transforms may be applied on the same
block of data.
.El
.El
.Pp
.Fn crypto_getreq
allocates a
.Fa cryptop
structure with a linked list of as many
.Fa cryptodesc
structures as were specified in the argument passed to it, which must
be at least 1.
.Pp
.Fn crypto_freereq
deallocates a structure
.Fa cryptop
and any
.Fa cryptodesc
structures linked to it.
Note that it is the responsibility of the
callback routine to do the necessary cleanups associated with the
opaque field in the
.Fa cryptop
structure.
.Pp
.Fn crypto_kdispatch
is called to perform a keying operation.
The various fields in the
.Fa crytokop
structure are:
.Bl -tag -width crp_alloctype
.It Fa krp_op
Operation code, such as CRK_MOD_EXP.
.It Fa krp_status
Return code.
This errno-style variable indicates whether there were lower level reasons
for operation failure.
.It Fa krp_iparams
Number of input parameters to the specified operation.
Note that each operation has a (typically hardwired) number of such parameters.
.It Fa krp_oparams
Number of output parameters from the specified operation.
Note that each operation has a (typically hardwired) number of such parameters.
.It Fa krp_kvp
An array of kernel memory blocks containing the parameters.
.It Fa krp_hid
Identifier specifying which low-level driver is being used.
.It Fa krp_callback
Callback called on completion of a keying operation.
.El
.Pp
.Fn crypto_kgetreq
allocates a
.Fa cryptkop
structure.
The first argument means the same as
.Fn crypto_getreq ,
except it is currently limited to be exactly 1.
The second argument means flags passed to
.Fn pool_get .
.Pp
.Fn crypto_kfreereq
deallocates a structure
.Fa cryptkop
structure.
.Pp
The following sysctl entries exist to adjust
the behaviour of the system from userland:
.Bl -tag -width opencrypto.crypto_ret_kq.maxlen
.It kern.usercrypto
Allow (1) or forbid (0) userland access to
.Pa /dev/crypto .
.It kern.userasymcrypto
Allow (1) or forbid (0) userland access to
do asymmetric crypto requests.
.It kern.cryptodevallowsoft
Enable/disable access to hardware versus software operations:
.Bl -tag -width xxx
.It < 0
Force userlevel requests to use software operations, always.
.It = 0
Use hardware if present, grant userlevel requests for non-accelerated
operations (handling the latter in software).
.It > 0
Allow user requests only for operations which are hardware-accelerated.
.El
.It opencrypto.crypto_ret_q.maxlen
Limit the length of queue(crypto_ret_q) which mediates between
crypto driver's completion and calling
.Fa cryptop
callback.
When the queue exceeds this limit,
.Fn crypto_getreq
fails.
.Bl -tag -width xxxx
.It <= 0
means unlimited.
.El
.It opencrypto.crypto_ret_kq.maxlen
Limit the length of queue(crypto_ret_kq) which mediates between
crypto driver's completion and calling
.Fa cryptkop
callback.
When the queue exceeds this limit,
.Fn crypto_kgetreq
fails.
.Bl -tag -width xxxx
.It <= 0
means unlimited.
.El
.El
.Pp
.Bl -tag -width opencrypto.crypto_ret_kq.drops
The following sysctl entries exist to get statistics.
.It opencrypto.crypto_ret_q.len
Current crypto_ret_q length.
.It opencrypto.crypto_ret_q.drops
The count of
.Fn crypto_getreq
failed as overflow
.Pa opencrypto.crypto_ret_q.maxlen .
.It opencrypto.crypto_ret_kq.len
Current crypto_ret_kq length.
.It opencrypto.crypto_ret_kq.drops
The count of
.Fn crypto_kgetreq
failed as overflow
.Pa opencrypto.crypto_ret_kq.maxlen .
.El
.Sh DRIVER-SIDE API
The
.Fn crypto_get_driverid ,
.Fn crypto_register ,
.Fn crypto_kregister ,
.Fn crypto_unregister ,
.Fn crypto_unregister_all ,
and
.Fn crypto_done
routines are used by drivers that provide support for cryptographic
primitives to register and unregister with the kernel crypto services
framework.
Drivers must first use the
.Fn crypto_get_driverid
function to acquire a driver identifier, specifying the
.Fa flags
as an argument (normally 0, but software-only drivers should specify
.Dv CRYPTOCAP_F_SOFTWARE ) .
For each algorithm the driver supports, it must then call
.Fn crypto_register .
The first argument is the driver identifier.
The second argument is an array of
.Dv CRYPTO_ALGORITHM_MAX + 1
elements, indicating which algorithms are supported.
The last three arguments are pointers to three
driver-provided functions that the framework may call to establish new
cryptographic context with the driver, free already established
context, and ask for a request to be processed (encrypt, decrypt,
etc.)
.Fn crypto_unregister
is called by drivers that wish to withdraw support for an algorithm.
The two arguments are the driver and algorithm identifiers, respectively.
algorithms supported by the card.
If all algorithms associated with a driver are unregistered, the
driver will be disabled (no new sessions will be allocated on that
driver, and any existing sessions will be migrated to other drivers).
.Fn crypto_unregister_all
will unregister all registered algorithms, disable the driver,
and migrate existing sessions to other drivers.
.Pp
The calling convention for the three driver-supplied routines is:
.Bd -literal
int (*newsession) (void *, u_int32_t *, struct cryptoini *);
void (*freesession) (void *, u_int64_t);
int (*process) (void *, struct cryptop *, int);
.Ed
.Pp
On invocation, the first argument to
.Fn newsession
contains the driver identifier obtained via
.Fn crypto_get_driverid .
On successfully returning, it should contain a driver-specific session
identifier.
The second argument is identical to that of
.Fn crypto_newsession .
.Pp
The
.Fn freesession
routine takes as argument the SID (which is the concatenation of the
driver identifier and the driver-specific session identifier returned
by
.Fn newsession ).
It should clear any context associated with the session (clear hardware
registers, memory, etc.).
.Pp
The
.Fn process
routine is invoked with a request to perform crypto processing.
This routine must not block, but should queue the request and return
immediately.
Upon processing the request, the callback routine should be invoked.
In case of error, the error indication must be placed in the
.Fa crp_etype
field of the
.Fa cryptop
structure.
The
.Fa hint
argument can be set to
.Dv CRYPTO_HINT_MORE
when there will be more request right after this request.
When the request is completed, or an error is detected, the
.Fn process
routine should invoke
.Fn crypto_done .
Session migration may be performed, as mentioned previously.
.Pp
The
.Fn kprocess
routine is invoked with a request to perform crypto key processing.
This routine must not block, but should queue the request and return
immediately.
Upon processing the request, the callback routine should be invoked.
In case of error, the error indication must be placed in the
.Fa krp_status
field of the
.Fa cryptkop
structure.
When the request is completed, or an error is detected, the
.Fn kprocess
routine should invoke
.Fn crypto_kdone .
.Sh RETURN VALUES
.Fn crypto_register ,
.Fn crypto_kregister ,
.Fn crypto_unregister ,
and
.Fn crypto_newsession
return 0 on success, or an error code on failure.
.Fn crypto_get_driverid
returns a non-negative value on error, and \-1 on failure.
.Fn crypto_getreq
returns a pointer to a
.Fa cryptop
structure and
.Dv NULL
on failure.
.Fn crypto_kgetreq
returns a pointer to a
.Fa cryptkop
structure and
.Dv NULL
on failure.
.Fn crypto_dispatch
arranges to invoke the callback with an error code
in the
.Fa crp_etype
field, or zero on success.
.Sh FILES
.Bl -tag -width sys/opencrypto/crypto.c
.It Pa sys/opencrypto/crypto.c
most of the framework code
.It Pa sys/crypto
crypto algorithm implementations
.El
.Sh SEE ALSO
.Xr ipsec 4 ,
.Xr pcmcia 4 ,
.Xr condvar 9 ,
.Xr malloc 9 ,
.Xr pool 9
.Rs
.%A "Angelos D. Keromytis"
.%A "Jason L. Wright"
.%A "Theo de Raadt"
.%T "The Design of the OpenBSD Cryptographic Framework"
.%I "Usenix"
.%N "2003"
.%D "June 2003"
.Re
.Sh HISTORY
The cryptographic framework first appeared in
.Ox 2.7
and was written by
.An Angelos D. Keromytis Aq Mt angelos@openbsd.org .
.Pp
.An Sam Leffler
ported the crypto framework to
.Fx
and made performance improvements.
.Pp
.An Jonathan Stone Aq Mt jonathan@NetBSD.org
ported the cryptoframe from
.Fx
to
.Nx .
.Nm opencrypto
first appeared in
.Nx 2.0 .
.Sh BUGS
The framework currently assumes that all the algorithms in a
.Fn crypto_newsession
operation must be available by the same driver.
If that's not the case, session initialization will fail.
.Pp
The framework also needs a mechanism for determining which driver is
best for a specific set of algorithms associated with a session.
Some type of benchmarking is in order here.
.Pp
Multiple instances of the same algorithm in the same session are not
supported.
Note that 3DES is considered one algorithm (and not three
instances of DES).
Thus, 3DES and DES could be mixed in the same request.