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
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
/*
 *  Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
 *
 *  Contact: Lukasz Pawelczyk <l.pawelczyk@samsung.com>
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License
 */


/// Enumeration of YACA key formats
#[derive(Debug, PartialEq)]
pub enum KeyFormat {
    /// Key is either PKCS#1 for RSA or SSLeay for DSA, also use this option for symmetric
    Default,
    /// Key is in PKCS#8, can only be used for asymmetric private keys
    Pkcs8,
}

/// Enumeration of YACA key file formats
#[derive(Debug, PartialEq)]
pub enum KeyFileFormat {
    /// Key file is in raw binary format, used for symmetric keys
    Raw,
    /// Key file is encoded in ASCII-base64, used for symmetric keys
    Base64,
    /// Key file is in PEM file format, used for asymmetric keys
    Pem,
    /// Key file is in DER file format, used for asymmetric keys
    Der,
}

/// Enumeration of YACA key types, Initialization Vector is considered as key
#[derive(Debug, PartialEq)]
pub enum KeyType {
    /// Generic symmetric cipher KEY
    Symmetric,
    /// DES* key - must be handled differently because of parity bits
    Des,
    /// Initialization Vector for symmetric algorithms
    Iv,
    /// RSA private key
    RsaPrivate,
    /// RSA public key
    RsaPublic,
    /// Digital Signature Algorithm private key
    DsaPrivate,
    /// Digital Signature Algorithm public key
    DsaPublic,
    /// Digital Signature Algorithm parameters
    DsaParams,
    /// Elliptic Curve private key for DSA and DH
    EcPrivate,
    /// Elliptic Curve public key for DSA and DH
    EcPublic,
    /// Elliptic Curve parameters
    EcParams,
    /// Diffie-Hellman key private key
    DhPrivate,
    /// Diffie-Hellman key public key
    DhPublic,
    /// Diffie-Hellman key parameters
    DhParams,
}

/// Enumeration of YACA key lengths
///
/// - For [`KeyType`]s: [`Symmetric`], [`DES`], [`IV`], [`RSA`] and [`DSA`] use `Bits`.
/// - For [`EC`] use `Ec`.
/// - For [`DH`] use `Dh`.
///
/// [`KeyType`]: enum.KeyType.html
/// [`Symmetric`]: enum.KeyType.html#variant.Symmetric
/// [`DES`]: enum.KeyType.html#variant.Des
/// [`IV`]: enum.KeyType.html#variant.Iv
/// [`RSA`]: enum.KeyType.html#variant.RsaPrivate
/// [`DSA`]: enum.KeyType.html#variant.DsaPrivate
/// [`EC`]: enum.KeyType.html#variant.EcPrivate
/// [`DH`]: enum.KeyType.html#variant.DhPrivate
#[derive(Debug, PartialEq)]
pub enum KeyLength {
    /// Key length represented by number of bits
    ///
    /// - `bits` needs to be divisible by 8.
    Bits(u16),
    /// Specific key lengths for Elliptic Curve keys
    Ec(KeyLengthEc),
    /// Specific key lengths for Diffie-Hellman key
    Dh(KeyLengthDh),
}

/// Enumeration of YACA elliptic curve types with their bit lengths
///
/// - It's meant to be passed or returned with [`KeyLength::Ec`] in
///   appropriate functions when dealing with elliptic curves.
///
/// [`KeyLength::Ec`]: enum.KeyLength.html#variant.Ec
#[derive(Debug, PartialEq)]
pub enum KeyLengthEc {
    /// Elliptic curve prime192v1
    Prime192V1,
    /// Elliptic curve prime192v2
    Prime192V2,
    /// Elliptic curve prime192v3
    Prime192V3,
    /// Elliptic curve prime239v1
    Prime239V1,
    /// Elliptic curve prime239v2
    Prime239V2,
    /// Elliptic curve prime239v3
    Prime239V3,
    /// Elliptic curve prime256v1
    Prime256V1,

    /// Elliptic curve c2pnb163v1
    C2pnb163V1,
    /// Elliptic curve c2pnb163v2
    C2pnb163V2,
    /// Elliptic curve c2pnb163v3
    C2pnb163V3,
    /// Elliptic curve c2pnb176v1
    C2pnb176V1,
    /// Elliptic curve c2tnb191v1
    C2tnb191V1,
    /// Elliptic curve c2tnb191v2
    C2tnb191V2,
    /// Elliptic curve c2tnb191v3
    C2tnb191V3,
    /// Elliptic curve c2pnb208w1
    C2pnb208W1,
    /// Elliptic curve c2tnb239v1
    C2tnb239V1,
    /// Elliptic curve c2tnb239v2
    C2tnb239V2,
    /// Elliptic curve c2tnb239v3
    C2tnb239V3,
    /// Elliptic curve c2pnb272w1
    C2pnb272W1,
    /// Elliptic curve c2pnb304w1
    C2pnb304W1,
    /// Elliptic curve c2tnb359v1
    C2tnb359V1,
    /// Elliptic curve c2pnb368w1
    C2pnb368W1,
    /// Elliptic curve c2tnb431r1
    C2tnb431R1,

    /// Elliptic curve secp112r1
    Secp112R1,
    /// Elliptic curve secp112r2
    Secp112R2,
    /// Elliptic curve secp128r1
    Secp128R1,
    /// Elliptic curve secp128r2
    Secp128R2,
    /// Elliptic curve secp160k1
    Secp160K1,
    /// Elliptic curve secp160r1
    Secp160R1,
    /// Elliptic curve secp160r2
    Secp160R2,
    /// Elliptic curve secp192k1
    Secp192K1,
    /// Elliptic curve secp224k1
    Secp224K1,
    /// Elliptic curve secp224r1
    Secp224R1,
    /// Elliptic curve secp256k1
    Secp256K1,
    /// Elliptic curve secp384r1
    Secp384R1,
    /// Elliptic curve secp521r1
    Secp521R1,

    /// Elliptic curve sect113r1
    Sect113R1,
    /// Elliptic curve sect113r2
    Sect113R2,
    /// Elliptic curve sect131r1
    Sect131R1,
    /// Elliptic curve sect131r2
    Sect131R2,
    /// Elliptic curve sect163k1
    Sect163K1,
    /// Elliptic curve sect163r1
    Sect163R1,
    /// Elliptic curve sect163r2
    Sect163R2,
    /// Elliptic curve sect193r1
    Sect193R1,
    /// Elliptic curve sect193r2
    Sect193R2,
    /// Elliptic curve sect233k1
    Sect233K1,
    /// Elliptic curve sect233r1
    Sect233R1,
    /// Elliptic curve sect239k1
    Sect239K1,
    /// Elliptic curve sect283k1
    Sect283K1,
    /// Elliptic curve sect283r1
    Sect283R1,
    /// Elliptic curve sect409k1
    Sect409K1,
    /// Elliptic curve sect409r1
    Sect409R1,
    /// Elliptic curve sect571k1
    Sect571K1,
    /// Elliptic curve sect571r1
    Sect571R1,

    /// Elliptic curve brainpoolP160r1
    BrainpoolP160R1,
    /// Elliptic curve brainpoolP160t1
    BrainpoolP160T1,
    /// Elliptic curve brainpoolP192r1
    BrainpoolP192R1,
    /// Elliptic curve brainpoolP192t1
    BrainpoolP192T1,
    /// Elliptic curve brainpoolP224r1
    BrainpoolP224R1,
    /// Elliptic curve brainpoolP224t1
    BrainpoolP224T1,
    /// Elliptic curve brainpoolP256r1
    BrainpoolP256R1,
    /// Elliptic curve brainpoolP256t1
    BrainpoolP256T1,
    /// Elliptic curve brainpoolP320r1
    BrainpoolP320R1,
    /// Elliptic curve brainpoolP320t1
    BrainpoolP320T1,
    /// Elliptic curve brainpoolP384r1
    BrainpoolP384R1,
    /// Elliptic curve brainpoolP384t1
    BrainpoolP384T1,
    /// Elliptic curve brainpoolP512r1
    BrainpoolP512R1,
    /// Elliptic curve brainpoolP512t1
    BrainpoolP512T1,
}

/// Enumeration of various YACA DH parameters including RFC 5114
///
/// - It's meant to be passed or returned with [`KeyLength::Dh`] in
///   appropriate functions when dealing with Diffie-Hellman.
///
/// [`KeyLength::Dh`]: enum.KeyLength.html#variant.Dh
#[derive(Debug, PartialEq)]
pub enum KeyLengthDh {
    /// RFC 5114 DH parameters 1024_160
    Rfc1024_160,
    /// RFC 5114 DH parameters 2048_224
    Rfc2048_224,
    /// RFC 5114 DH parameters 2048_256
    Rfc2048_256,
    /// Generator equal 2 for DH parameters
    ///
    /// - Needs specifying safe prime length in bits.
    /// - Prime length needs to be >= 256 and divisble by 8.
    /// - Prime length is recommended to be 2048 bits or higher.
    Generator2Bits(u16),
    /// Generator equal 5 for DH parameters
    ///
    /// - Needs specifying safe prime length in bits.
    /// - Prime length needs to be >= 256 and divisble by 8.
    /// - Prime length is recommended to be 2048 bits or higher.
    Generator5Bits(u16),
}

/// Enumeration of YACA message digest algorithms
#[derive(Debug, PartialEq)]
pub enum DigestAlgorithm {
    /// Message digest algorithm MD5
    Md5,
    /// Message digest algorithm SHA1
    Sha1,
    /// Message digest algorithm SHA2, 224bit
    Sha224,
    /// Message digest algorithm SHA2, 256bit
    Sha256,
    /// Message digest algorithm SHA2, 384bit
    Sha384,
    /// Message digest algorithm SHA2, 512bit
    Sha512,
}

/// Enumeration of YACA symmetric encryption algorithms
#[derive(Debug, PartialEq)]
pub enum EncryptAlgorithm {
    /// AES encryption
    ///
    /// - Supported key lengths: [`128`], [`192`] and [`256`] bits.
    /// - Supported block cipher modes:
    ///   * [`CBC`],
    ///   * [`OFB`],
    ///   * [`CFB`],
    ///   * [`CFB1`],
    ///   * [`CFB8`],
    ///   * [`ECB`],
    ///   * [`GCM`],
    ///   * [`CCM`],
    ///   * [`CTR`],
    ///   * [`Wrap`].
    /// - See [`BlockCipherMode`] for details on additional properties (mandatory).
    ///
    /// [`128`]: enum.KeyLength.html#variant.Bits
    /// [`192`]: enum.KeyLength.html#variant.Bits
    /// [`256`]: enum.KeyLength.html#variant.Bits
    /// [`CBC`]: enum.BlockCipherMode.html#variant.Cbc
    /// [`OFB`]: enum.BlockCipherMode.html#variant.Ofb
    /// [`CFB`]: enum.BlockCipherMode.html#variant.Cfb
    /// [`CFB1`]: enum.BlockCipherMode.html#variant.Cfb1
    /// [`CFB8`]: enum.BlockCipherMode.html#variant.Cfb8
    /// [`ECB`]: enum.BlockCipherMode.html#variant.Ecb
    /// [`GCM`]: enum.BlockCipherMode.html#variant.Gcm
    /// [`CCM`]: enum.BlockCipherMode.html#variant.Ccm
    /// [`CTR`]: enum.BlockCipherMode.html#variant.Ctr
    /// [`Wrap`]: enum.BlockCipherMode.html#variant.Wrap
    /// [`BlockCipherMode`]: enum.BlockCipherMode.html
    Aes,

    /// DES encryption (unsafe)
    ///
    /// - Supported key lengths: [`64`] bits.
    /// - Supported block cipher modes:
    ///   * [`CBC`],
    ///   * [`OFB`],
    ///   * [`CFB`],
    ///   * [`CFB1`],
    ///   * [`CFB8`],
    ///   * [`ECB`].
    /// - See [`BlockCipherMode`] for details on additional properties (mandatory).
    ///
    /// [`64`]: enum.KeyLength.html#variant.Bits
    /// [`CBC`]: enum.BlockCipherMode.html#variant.Cbc
    /// [`OFB`]: enum.BlockCipherMode.html#variant.Ofb
    /// [`CFB`]: enum.BlockCipherMode.html#variant.Cfb
    /// [`CFB1`]: enum.BlockCipherMode.html#variant.Cfb1
    /// [`CFB8`]: enum.BlockCipherMode.html#variant.Cfb8
    /// [`ECB`]: enum.BlockCipherMode.html#variant.Ecb
    /// [`BlockCipherMode`]: enum.BlockCipherMode.html
    UnsafeDes,

    /// 3DES 2-key encryption (unsafe)
    ///
    /// - Supported key lengths: [`128`] bits.
    /// - Supported block cipher modes:
    ///   * [`CBC`],
    ///   * [`OFB`],
    ///   * [`CFB`],
    ///   * [`ECB`].
    /// - See [`BlockCipherMode`] for details on additional properties (mandatory).
    /// - Use double [`DES`] keys to perform corresponding 2-key 3DES encryption.
    ///
    /// [`128`]: enum.KeyLength.html#variant.Bits
    /// [`CBC`]: enum.BlockCipherMode.html#variant.Cbc
    /// [`OFB`]: enum.BlockCipherMode.html#variant.Ofb
    /// [`CFB`]: enum.BlockCipherMode.html#variant.Cfb
    /// [`ECB`]: enum.BlockCipherMode.html#variant.Ecb
    /// [`BlockCipherMode`]: enum.BlockCipherMode.html
    /// [`DES`]: enum.KeyType.html#variant.Des
    UnsafeTripleDes2Tdea,

    /// 3DES 3-key encryption
    ///
    /// - Supported key lengths: [`192`] bits.
    /// - Supported block cipher modes:
    ///   * [`CBC`],
    ///   * [`OFB`],
    ///   * [`CFB`],
    ///   * [`CFB1`],
    ///   * [`CFB8`],
    ///   * [`ECB`],
    ///   * [`Wrap`].
    /// - See [`BlockCipherMode`] for details on additional properties (mandatory).
    /// - Use triple [`DES`] keys to perform corresponding 3-key 3DES encryption.
    ///
    /// [`192`]: enum.KeyLength.html#variant.Bits
    /// [`CBC`]: enum.BlockCipherMode.html#variant.Cbc
    /// [`OFB`]: enum.BlockCipherMode.html#variant.Ofb
    /// [`CFB`]: enum.BlockCipherMode.html#variant.Cfb
    /// [`CFB1`]: enum.BlockCipherMode.html#variant.Cfb1
    /// [`CFB8`]: enum.BlockCipherMode.html#variant.Cfb8
    /// [`ECB`]: enum.BlockCipherMode.html#variant.Ecb
    /// [`Wrap`]: enum.BlockCipherMode.html#variant.Wrap
    /// [`BlockCipherMode`]: enum.BlockCipherMode.html
    /// [`DES`]: enum.KeyType.html#variant.Des
    TripleDes3Tdea,

    /// RC2 encryption (unsafe)
    ///
    /// - This is a variable key length cipher.
    /// - Supported key lengths: 8-1024 bits in steps of 8 bits.
    /// - Effective key bits property by default equals to 128 bits.
    ///   Possible values are 1-1024 in steps of 1 bit.
    ///   Effective key bits can be set using [`CtxRc2::set_property_rc2_effective_key_bits()`].  
    ///   It can be set after [`EncryptContext::initialize()`] / [`DecryptContext::initialize()`],
    ///   and before [`EncryptContext::update()`] / [`DecryptContext::update()`] in
    ///   `Encrypt`/`Decrypt` operation.
    /// - Supported block cipher modes:
    ///   * [`CBC`],
    ///   * [`OFB`],
    ///   * [`CFB`],
    ///   * [`ECB`].
    /// - See [`BlockCipherMode`] for details on additional properties (mandatory).
    ///
    /// [`CtxRc2::set_property_rc2_effective_key_bits()`]: trait.ContextWithRc2Supported.html#method.set_property_rc2_effective_key_bits
    /// [`EncryptContext::initialize()`]: struct.EncryptContext.html#method.initialize
    /// [`DecryptContext::initialize()`]: struct.DecryptContext.html#method.initialize
    /// [`EncryptContext::update()`]: struct.EncryptContext.html#method.update
    /// [`DecryptContext::update()`]: struct.DecryptContext.html#method.update
    /// [`CBC`]: enum.BlockCipherMode.html#variant.Cbc
    /// [`OFB`]: enum.BlockCipherMode.html#variant.Ofb
    /// [`CFB`]: enum.BlockCipherMode.html#variant.Cfb
    /// [`ECB`]: enum.BlockCipherMode.html#variant.Ecb
    /// [`BlockCipherMode`]: enum.BlockCipherMode.html
    UnsafeRc2,

    /// RC4 encryption (unsafe)
    ///
    /// - This is a variable key length cipher.
    /// - Supported key lengths: 40–2048 bits in steps of 8 bits.
    /// - Initialization Vector is not used.
    /// - This cipher doesn't support block cipher modes, use [`BlockCipherMode::None`] instead.
    ///
    /// [`BlockCipherMode::None`]: enum.BlockCipherMode.html#variant.None
    UnsafeRc4,

    /// CAST5 encryption
    ///
    /// - This is a variable key length cipher.
    /// - Supported key lengths: 40-128 bits in steps of 8 bits.
    /// - Supported block cipher modes:
    ///   * [`CBC`],
    ///   * [`OFB`],
    ///   * [`CFB`],
    ///   * [`ECB`].
    /// - See [`BlockCipherMode`] for details on additional properties (mandatory).
    ///
    /// [`CBC`]: enum.BlockCipherMode.html#variant.Cbc
    /// [`OFB`]: enum.BlockCipherMode.html#variant.Ofb
    /// [`CFB`]: enum.BlockCipherMode.html#variant.Cfb
    /// [`ECB`]: enum.BlockCipherMode.html#variant.Ecb
    /// [`BlockCipherMode`]: enum.BlockCipherMode.html
    Cast5,
}

/// Enumeration of YACA chaining modes for block ciphers
#[derive(Debug, PartialEq)]
pub enum BlockCipherMode {
    /// Used when algorithm doesn't support block ciphers modes.
    ///
    /// - Initialization Vector is not used.
    None,

    /// ECB block cipher mode.
    ///
    /// - Initialization Vector is not used.
    /// - By default the input data is padded using standard block
    ///   padding [`PKCS7`].
    /// - Padding can be disabled using
    ///   [`CtxPad::set_property_padding()`] and [`Padding::None`].
    ///   The total length of data passed until `*::finalize()` must
    ///   be a multiple of block size in such case.
    /// - In case of `Encrypt`/`Seal` [`Padding`] can be set at
    ///   the latest before the `*::finalize()` call. In case of
    ///   `Decrypt`/`Open` it can be set at the latest before the
    ///   `*::update()` call.
    ///
    /// [`PKCS7`]: enum.Padding.html#variant.Pkcs7
    /// [`CtxPad::set_property_padding()`]: trait.ContextWithPadding.html#method.set_property_padding
    /// [`Padding::None`]: enum.Padding.html#variant.None
    /// [`Padding`]: enum.Padding.html
    Ecb,

    /// CTR block cipher mode
    ///
    /// - 128-bit [`Initialization Vector`] for [`AES`],
    ///   64-bit for other algorithms is mandatory.
    ///
    /// [`Initialization Vector`]: enum.KeyType.html#variant.Iv
    /// [`AES`]: enum.EncryptAlgorithm.html#variant.Aes
    Ctr,

    /// CBC block cipher mode
    ///
    /// - 128-bit [`Initialization Vector`] for [`AES`].
    /// - 64-bit for other algorithms is mandatory.
    /// - By default the input data is padded using standard block
    ///   padding [`PKCS7`].
    /// - Padding can be disabled using
    ///   [`CtxPad::set_property_padding`] and [`Padding::None`].
    ///   The total length of data passed until `*::finalize()` must
    ///   be a multiple of block size in such case.
    /// - In case of `Encrypt`/`Seal` [`Padding`] can be set at
    ///   the latest before the `*::finalize()` call. In case of
    ///   `Decrypt`/`Open` it can be set at the latest before the
    ///   `*::update()` call.
    ///
    /// [`Initialization Vector`]: enum.KeyType.html#variant.Iv
    /// [`AES`]: enum.EncryptAlgorithm.html#variant.Aes
    /// [`PKCS7`]: enum.Padding.html#variant.Pkcs7
    /// [`CtxPad::set_property_padding`]: trait.ContextWithPadding.html#method.set_property_padding
    /// [`Padding::None`]: enum.Padding.html#variant.None
    /// [`Padding`]: enum.Padding.html
    Cbc,

    /// GCM block cipher mode
    ///
    /// - This is a variable [`Initialization Vector`] length mode (recommended 96-bits).
    /// - Supported properties:
    ///   * GCM tag length (optional)  
    ///     [`CtxXcmEnc::set_property_gcm_tag_len()`]  
    ///     Supported tag lengths: 4, 8, 12, 13, 14, 15, 16 (16 bytes tag by default).  
    ///     Set after [`EncryptContext::finalize()`] / [`SealContext::finalize()`] and before
    ///     [`CtxXcmEnc::get_property_gcm_tag()`] in `Encryption`/`Seal` operation.
    ///     In `Decryption`/`Open` operation tag length is not set.
    ///   * GCM tag  
    ///     [`CtxXcmEnc::get_property_gcm_tag()`]  
    ///     [`CtxXcmDec::set_property_gcm_tag()`]  
    ///     Get after [`EncryptContext::finalize()`] / [`SealContext::finalize()`] in `Encryption`/`Seal` operation.  
    ///     Set after [`DecryptContext::update()`] / [`OpenContext::update()`] and before
    ///     [`DecryptContext::finalize()`] / [`OpenContext::finalize()`] in `Decryption`/`Open` operation.
    ///   * AAD - additional authentication data (optional)  
    ///     [`CtxXcmEnc::set_property_gcm_aad()`]  
    ///     [`CtxXcmDec::set_property_gcm_aad()`]  
    ///     AAD length can have any positive value.  
    ///     Set after [`EncryptContext::initialize()`] / [`SealContext::initialize()`] and before
    ///     [`EncryptContext::update()`] / [`SealContext::update()`] in `Encryption`/`Seal` operation.  
    ///     Set after [`DecryptContext::initialize()`] / [`OpenContext::initialize()`] and before
    ///     [`DecryptContext::update()`] / [`OpenContext::update()`] in `Decryption`/`Open` operation.
    ///
    /// [`Initialization Vector`]: enum.KeyType.html#variant.Iv
    /// [`CtxXcmEnc::set_property_gcm_tag_len()`]: trait.ContextWithXcmEncryptProperties.html#method.set_property_gcm_tag_len
    /// [`EncryptContext::finalize()`]: struct.EncryptContext.html#method.finalize
    /// [`SealContext::finalize()`]: struct.SealContext.html#method.finalize
    /// [`CtxXcmEnc::get_property_gcm_tag()`]: trait.ContextWithXcmEncryptProperties.html#method.get_property_gcm_tag
    /// [`CtxXcmDec::set_property_gcm_tag()`]: trait.ContextWithXcmDecryptProperties.html#method.set_property_gcm_tag
    /// [`DecryptContext::update()`]: struct.DecryptContext.html#method.update
    /// [`OpenContext::update()`]: struct.OpenContext.html#method.update
    /// [`DecryptContext::finalize()`]: struct.DecryptContext.html#method.finalize
    /// [`OpenContext::finalize()`]: struct.OpenContext.html#method.finalize
    /// [`CtxXcmEnc::set_property_gcm_aad()`]: trait.ContextWithXcmEncryptProperties.html#method.set_property_gcm_aad
    /// [`CtxXcmDec::set_property_gcm_aad()`]: trait.ContextWithXcmDecryptProperties.html#method.set_property_gcm_aad
    /// [`EncryptContext::initialize()`]: struct.EncryptContext.html#method.initialize
    /// [`SealContext::initialize()`]: struct.SealContext.html#method.initialize
    /// [`EncryptContext::update()`]: struct.EncryptContext.html#method.update
    /// [`SealContext::update()`]: struct.SealContext.html#method.update
    /// [`DecryptContext::initialize()`]: struct.DecryptContext.html#method.initialize
    /// [`OpenContext::initialize()`]: struct.OpenContext.html#method.initialize
    Gcm,

    /// Default CFB block cipher mode
    ///
    /// - 128-bit [`Initialization Vector`] for [`AES`],
    ///   64-bit for other algorithms is mandatory.
    ///
    /// [`Initialization Vector`]: enum.KeyType.html#variant.Iv
    /// [`AES`]: enum.EncryptAlgorithm.html#variant.Aes
    Cfb,

    /// 1 bit CFB block cipher mode
    ///
    /// - 128-bit [`Initialization Vector`] for [`AES`],
    ///   64-bit for other algorithms is mandatory.
    ///
    /// [`Initialization Vector`]: enum.KeyType.html#variant.Iv
    /// [`AES`]: enum.EncryptAlgorithm.html#variant.Aes
    Cfb1,

    /// 8 bits CFB block cipher mode
    ///
    /// - 128-bit [`Initialization Vector`] for [`AES`],
    ///   64-bit for other algorithms is mandatory.
    ///
    /// [`Initialization Vector`]: enum.KeyType.html#variant.Iv
    /// [`AES`]: enum.EncryptAlgorithm.html#variant.Aes
    Cfb8,

    /// OFB block cipher mode
    ///
    /// - 128-bit [`Initialization Vector`] for [`AES`],
    ///   64-bit for other algorithms is mandatory.
    ///
    /// [`Initialization Vector`]: enum.KeyType.html#variant.Iv
    /// [`AES`]: enum.EncryptAlgorithm.html#variant.Aes
    Ofb,

    /// CBC-MAC Mode (AES)
    ///
    /// - This is a variable [`Initialization Vector`] length mode.
    /// - Supported [`Initialization Vector`] lengths: 56-104 bits in steps of 8 bits
    ///   (recommended 56-bits).
    /// - Supported properties:
    ///   * CCM tag length (optional)  
    ///     [`CtxXcmEnc::set_property_ccm_tag_len()`]  
    ///     Supported tag lengths: 4-16 bytes in steps of 2 bytes (12 bytes tag by default).  
    ///     Set after [`EncryptContext::initialize()`] / [`SealContext::initialize()`] and before
    ///     [`EncryptContext::update()`] / [`SealContext::update()`] in `Encryption`/`Seal` operation.  
    ///     In `Decryption`/`Open` operation tag length is not set.  
    ///   * CCM tag  
    ///     [`CtxXcmEnc::get_property_ccm_tag()`]  
    ///     [`CtxXcmDec::set_property_ccm_tag()`]  
    ///     Get after [`EncryptContext::finalize()`] / [`SealContext::finalize()`] in `Encryption`/`Seal` operation.  
    ///     Set after [`DecryptContext::initialize()`] / [`OpenContext::initialize()`] and before
    ///     [`DecryptContext::update()`] / [`OpenContext::update()`] in decryption / open operation.  
    ///   * AAD - additional authentication data (optional)  
    ///     [`CtxXcmEnc::set_property_ccm_aad()`]  
    ///     [`CtxXcmDec::set_property_ccm_aad()`]  
    ///     AAD length can have any positive value.
    ///
    ///     The total plaintext length must be passed to [`CtxXcmEnc::set_property_ccm_aad()`] if AAD is used.  
    ///     Set after [`EncryptContext::initialize()`] / [`SealContext::initialize()`] and before
    ///     [`EncryptContext::update()`] / [`SealContext::update()`] in `Encryption`/`Seal` operation.
    ///
    ///     The total ciphertext length must be passed to [`CtxXcmDec::set_property_ccm_aad()`] if AAD is used.  
    ///     Set after [`DecryptContext::initialize()`] / [`OpenContext::initialize()`] and before
    ///     [`DecryptContext::update()`] / [`OpenContext::update()`] in `Decryption`/`Open` operation.
    ///
    /// - You can only call [`EncryptContext::update()`] / [`SealContext::update()`] once for the plaintext.  
    ///   You can only call [`DecryptContext::update()`] / [`OpenContext::update()`] once for the ciphertext.
    ///
    /// [`Initialization Vector`]: enum.KeyType.html#variant.Iv
    /// [`CtxXcmEnc::set_property_ccm_tag_len()`]: trait.ContextWithXcmEncryptProperties.html#method.set_property_ccm_tag_len
    /// [`EncryptContext::initialize()`]: struct.EncryptContext.html#method.initialize
    /// [`SealContext::initialize()`]: struct.SealContext.html#method.initialize
    /// [`EncryptContext::update()`]: struct.EncryptContext.html#method.update
    /// [`SealContext::update()`]: struct.SealContext.html#method.update
    /// [`CtxXcmEnc::get_property_ccm_tag()`]: trait.ContextWithXcmEncryptProperties.html#method.get_property_ccm_tag
    /// [`CtxXcmDec::set_property_ccm_tag()`]: trait.ContextWithXcmDecryptProperties.html#method.set_property_ccm_tag
    /// [`EncryptContext::finalize()`]: struct.EncryptContext.html#method.finalize
    /// [`SealContext::finalize()`]: struct.SealContext.html#method.finalize
    /// [`DecryptContext::initialize()`]: struct.DecryptContext.html#method.initialize
    /// [`OpenContext::initialize()`]: struct.OpenContext.html#method.initialize
    /// [`DecryptContext::update()`]: struct.DecryptContext.html#method.update
    /// [`OpenContext::update()`]: struct.OpenContext.html#method.update
    /// [`CtxXcmEnc::set_property_ccm_aad()`]: trait.ContextWithXcmEncryptProperties.html#method.set_property_ccm_aad
    /// [`CtxXcmDec::set_property_ccm_aad()`]: trait.ContextWithXcmDecryptProperties.html#method.set_property_ccm_aad
    Ccm,

    /// Used with [`AES`] or [`3DES_3TDEA`] to perform a key wrapping
    /// (key material symmetric encryption)
    ///
    /// - Only a single [`EncryptContext::update()`] / [`DecryptContext::update()`] is allowed.
    /// - Usage in [`SealContext::initialize()`] / [`OpenContext::initialize()`] is forbidden.
    /// - Key used to do the wrapping with [`EncryptAlgorithm::Aes`] can be a [`128`], [`192`] or a [`256`] bit key.  
    ///   [`64`] bit [`Initialization Vector`] is used.  
    ///   Wrapped key can be a [`128`], [`192`], or a [`256`] bit key.  
    ///   [`EncryptAlgorithm::Aes`] allows wrapping multiple keys together.
    /// - Key used to do the wrapping with [`EncryptAlgorithm::UnsafeTripleDes2Tdea`] can be a [`192`] bit [`DES`] key only.
    ///   Initialization Vector is not used.  
    ///   Wrapped key can be a [`128`] bit [`DES`] key (two-key), or a [`192`] bit [`DES`] key (three-key).  
    ///   [`EncryptAlgorithm::UnsafeTripleDes2Tdea`] allows wrapping only one key.
    ///
    /// [`AES`]: enum.EncryptAlgorithm.html#variant.Aes
    /// [`Initialization Vector`]: enum.KeyType.html#variant.Iv
    /// [`3DES_3TDEA`]: enum.EncryptAlgorithm.html#variant.UnsafeTripleDes2Tdea
    /// [`EncryptContext::update()`]: struct.EncryptContext.html#method.update
    /// [`DecryptContext::update()`]: struct.DecryptContext.html#method.update
    /// [`SealContext::initialize()`]: struct.SealContext.html#method.initialize
    /// [`OpenContext::initialize()`]: struct.OpenContext.html#method.initialize
    /// [`EncryptAlgorithm::Aes`]: enum.EncryptAlgorithm.html#variant.Aes
    /// [`EncryptAlgorithm::UnsafeTripleDes2Tdea`]: enum.EncryptAlgorithm.html#variant.UnsafeTrippleDes2Tdea
    /// [`64`]: enum.KeyLength.html#variant.Bits
    /// [`128`]: enum.KeyLength.html#variant.Bits
    /// [`192`]: enum.KeyLength.html#variant.Bits
    /// [`256`]: enum.KeyLength.html#variant.Bits
    /// [`DES`]: enum.KeyType.html#variant.Des
    Wrap,
}

// Used by Context property functions
#[derive(Debug, PartialEq)]
pub(crate) enum Property {
    Padding,
    GcmAad,
    GcmTag,
    GcmTagLen,
    CcmAad,
    CcmTag,
    CcmTagLen,
    Rc2EffectiveKeyBits,
}

/// Enumeration of YACA paddings
#[derive(Debug, PartialEq)]
pub enum Padding {
    /// No padding at all. This method assumes that the input data
    /// already has a proper length for a given cryptographic
    /// operation (e.g. it has been padded by the client). Suitable
    /// for symmetric `Encrypt`/`Decrypt` operations as well as low-level
    /// `RSA` operations.
    None,

    /// X9.31 padding. Suitable for `RSA` `Sign`/`Verify` operation. Not
    /// supported in low-level `RSA` operations.
    X931,

    /// PKCS #1 v1.5 padding. Suitable for `RSA` `Sign`/`Verify` and
    /// low-level `RSA` operations. For low-level operations the input
    /// must be at least 11 bytes shorter than the key length.
    Pkcs1,

    /// PKCS #1 PSS padding. Suitable for `RSA` `Sign`/`Verify`
    /// operations. Not supported in low-level `RSA` operations.
    Pkcs1Pss,

    /// EME-OAEP as defined in PKCS #1 v2.0 with SHA-1, MGF1 and an
    /// empty encoding parameter. Suitable for low-level `RSA`
    /// `public_encrypt`/`private_decrypt` operations. For low-level
    /// operations the input must be at least 42 bytes shorter than
    /// the key length.
    Pkcs1Oaep,

    /// PKCS #1 v1.5 padding with an SSL-specific modification that
    /// denotes that the party is SSL3 capable. It is used for
    /// rollback attack detection in SSLv3. If during decryption it
    /// turns out that both parties are using `Pkcs1SslV23` (both are
    /// communicating using SSL2 and both are SSL3 capable) it is
    /// treated as a rollback attack and an error is
    /// returned. Suitable for low-level `RSA`
    /// `public_encrypt`/`private_decrypt` operations. For low-level
    /// operations the input must be at least 11 bytes shorter than
    /// the key length.
    Pkcs1SslV23,

    /// PKCS #7 padding. Suitable for symmetric `Encrypt`/`Decrypt` operation.
    Pkcs7,
}

/// Enumeration of YACA key derivation functions
#[derive(Debug, PartialEq)]
pub enum Kdf {
    /// ANSI X9.42 key derivation function, (shared secret derived
    /// using Diffie-Hellman key exchange protocol).
    X942,

    /// ANSI X9.62 key derivation function, (shared secret derived
    /// using EC Diffie-Hellman key exchange protocol).
    X962,
}

// Local Variables:
// delete-trailing-whitespace-on-save: nil
// End: