@@ -508,133 +508,6 @@ public override string ToString()
508
508
}
509
509
}
510
510
511
- /// <summary>
512
- ///
513
- /// These functions provide an interface for the Chacha20 encryption primitive.
514
- /// <br/>
515
- ///
516
- /// Chacha20 is a low-level primitive. Consider using authenticated encryption,
517
- /// implemented by <see cref="crypto_lock"/>.
518
- /// <br/>
519
- ///
520
- /// This overrides considers plain_text input as if it was composed of all of input zero.
521
- ///
522
- /// </summary>
523
- /// <param name="key">A 32-byte secret key.</param>
524
- /// <param name="nonce">A 8-byte buffer. An 8-byte or 24-byte number, used only once with any given key. It does
525
- /// not need to be secret or random, but it does have to be unique. Repeating
526
- /// a nonce with the same key reveals the XOR of two different messages, which
527
- /// allows decryption. 24-byte nonces can be selected at random. 8-byte nonces
528
- /// cannot. They are too small, and the same
529
- /// nonce may be selected twice by accident. See
530
- /// intro(3monocypher) for advice about
531
- /// generating random numbers (use the operating system's random number
532
- /// generator).</param>
533
- /// <param name="cipher_text">The encrypted message.</param>
534
- public static unsafe void crypto_chacha20 ( Span < byte > cipher_text , ReadOnlySpan < byte > key , ReadOnlySpan < byte > nonce )
535
- {
536
- ExpectSize32 ( nameof ( key ) , key . Length ) ;
537
- ExpectSize8 ( nameof ( nonce ) , nonce . Length ) ;
538
- fixed ( void * cipher_text_ptr = cipher_text )
539
- crypto_chacha20 ( new IntPtr ( cipher_text_ptr ) , IntPtr . Zero , ( Monocypher . size_t ) cipher_text . Length , in key . AsByte32 ( ) , in nonce . AsByte8 ( ) ) ;
540
- }
541
-
542
-
543
- /// <summary>
544
- ///
545
- /// These functions provide an interface for the Chacha20 encryption primitive.
546
- /// <br/>
547
- ///
548
- /// Chacha20 is a low-level primitive. Consider using authenticated encryption,
549
- /// implemented by <see cref="crypto_lock"/>.
550
- /// <br/>
551
- ///
552
- /// This overrides considers plain_text input as if it was composed of all of input zero.
553
- ///
554
- /// </summary>
555
- /// <param name="key">A 32-byte secret key.</param>
556
- /// <param name="nonce">A 24-byte buffer. An 8-byte or 24-byte number, used only once with any given key. It does
557
- /// not need to be secret or random, but it does have to be unique. Repeating
558
- /// a nonce with the same key reveals the XOR of two different messages, which
559
- /// allows decryption. 24-byte nonces can be selected at random. 8-byte nonces
560
- /// cannot. They are too small, and the same
561
- /// nonce may be selected twice by accident. See
562
- /// intro(3monocypher) for advice about
563
- /// generating random numbers (use the operating system's random number
564
- /// generator).</param>
565
- /// <param name="cipher_text">The encrypted message.</param>
566
- public static unsafe void crypto_xchacha20 ( Span < byte > cipher_text , ReadOnlySpan < byte > key , ReadOnlySpan < byte > nonce )
567
- {
568
- ExpectSize32 ( nameof ( key ) , key . Length ) ;
569
- ExpectSize24 ( nameof ( nonce ) , nonce . Length ) ;
570
- fixed ( void * cipher_text_ptr = cipher_text )
571
- crypto_xchacha20 ( new IntPtr ( cipher_text_ptr ) , IntPtr . Zero , ( Monocypher . size_t ) cipher_text . Length , in key . AsByte32 ( ) , in nonce . AsByte24 ( ) ) ;
572
- }
573
-
574
- /// <summary>
575
- ///
576
- /// These functions provide an interface for the Chacha20 encryption primitive.
577
- /// <br/>
578
- ///
579
- /// Chacha20 is a low-level primitive. Consider using authenticated encryption,
580
- /// implemented by <see cref="crypto_lock"/>.
581
- /// <br/>
582
- ///
583
- /// This overrides considers plain_text input as if it was composed of all of input zero.
584
- ///
585
- /// </summary>
586
- /// <param name="key">A 32-byte secret key.</param>
587
- /// <param name="nonce">A 8-byte buffer. An 8-byte or 24-byte number, used only once with any given key. It does
588
- /// not need to be secret or random, but it does have to be unique. Repeating
589
- /// a nonce with the same key reveals the XOR of two different messages, which
590
- /// allows decryption. 24-byte nonces can be selected at random. 8-byte nonces
591
- /// cannot. They are too small, and the same
592
- /// nonce may be selected twice by accident. See
593
- /// intro(3monocypher) for advice about
594
- /// generating random numbers (use the operating system's random number
595
- /// generator).</param>
596
- /// <param name="cipher_text">The encrypted message.</param>
597
- /// <param name="ctr">The number of 64-byte blocks since the beginning of the stream.</param>
598
- public static unsafe ulong crypto_chacha20_ctr ( Span < byte > cipher_text , ReadOnlySpan < byte > key , ReadOnlySpan < byte > nonce , ulong ctr )
599
- {
600
- ExpectSize32 ( nameof ( key ) , key . Length ) ;
601
- ExpectSize8 ( nameof ( nonce ) , nonce . Length ) ;
602
- fixed ( void * cipher_text_ptr = cipher_text )
603
- return crypto_chacha20_ctr ( new IntPtr ( cipher_text_ptr ) , IntPtr . Zero , ( Monocypher . size_t ) cipher_text . Length , in key . AsByte32 ( ) , in nonce . AsByte8 ( ) , ctr ) ;
604
- }
605
-
606
- /// <summary>
607
- ///
608
- /// These functions provide an interface for the Chacha20 encryption primitive.
609
- /// <br/>
610
- ///
611
- /// Chacha20 is a low-level primitive. Consider using authenticated encryption,
612
- /// implemented by <see cref="crypto_lock"/>.
613
- /// <br/>
614
- ///
615
- /// This overrides considers plain_text input as if it was composed of all of input zero.
616
- ///
617
- /// </summary>
618
- /// <param name="key">A 32-byte secret key.</param>
619
- /// <param name="nonce">A 24-byte buffer. An 8-byte or 24-byte number, used only once with any given key. It does
620
- /// not need to be secret or random, but it does have to be unique. Repeating
621
- /// a nonce with the same key reveals the XOR of two different messages, which
622
- /// allows decryption. 24-byte nonces can be selected at random. 8-byte nonces
623
- /// cannot. They are too small, and the same
624
- /// nonce may be selected twice by accident. See
625
- /// intro(3monocypher) for advice about
626
- /// generating random numbers (use the operating system's random number
627
- /// generator).</param>
628
- /// <param name="cipher_text">The encrypted message.</param>
629
- /// <param name="ctr">The number of 64-byte blocks since the beginning of the stream.</param>
630
- public static unsafe ulong crypto_xchacha20_ctr ( Span < byte > cipher_text , ReadOnlySpan < byte > key , ReadOnlySpan < byte > nonce , ulong ctr )
631
- {
632
- ExpectSize32 ( nameof ( key ) , key . Length ) ;
633
- ExpectSize24 ( nameof ( nonce ) , nonce . Length ) ;
634
- fixed ( void * cipher_text_ptr = cipher_text )
635
- return crypto_xchacha20_ctr ( new IntPtr ( cipher_text_ptr ) , IntPtr . Zero , ( Monocypher . size_t ) cipher_text . Length , in key . AsByte32 ( ) , in nonce . AsByte24 ( ) , ctr ) ;
636
- }
637
-
638
511
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
639
512
private static char ByteHighToHex ( byte value ) => HexBytes [ ( value >> 4 ) & 0x0F ] ;
640
513
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
0 commit comments