Skip to content

Commit

Permalink
updated documentation (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheroz committed Aug 5, 2023
1 parent f074cd1 commit a6200f2
Show file tree
Hide file tree
Showing 15 changed files with 83 additions and 53 deletions.
12 changes: 6 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

All notable changes to this project will be documented in this file.

## 0.7.0 (2023-08-05)
## 0.7.1 (2023-08-05)

### Added
- Updated documentation

- Support for streaming
- File encryption sample
## 0.7.0 (2023-08-05)

## 0.6.3 (2023-07-27)
- Added support for streaming
- Added file encryption sample

### Updated
## 0.6.3 (2023-07-27)

- Updated documentation
11 changes: 10 additions & 1 deletion cipher_magma/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

All notable changes to this project will be documented in this file.

## 0.7.1 (2023-08-05)

- Updated documentation

## 0.7.0 (2023-08-05)

- Added support for streaming
- Added file encryption sample

## 0.6.3 (2023-07-27)

* Updated documentation
- Updated documentation
2 changes: 1 addition & 1 deletion cipher_magma/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cipher_magma"
version = "0.7.0"
version = "0.7.1"
edition = "2021"
authors = ["Sheroz Khaydarov"]
description = "Block Cipher Magma (GOST R 34.12-2015, former GOST 28147-89)"
Expand Down
16 changes: 16 additions & 0 deletions cipher_magma/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
//! Block Cipher "Magma"
//!
//! Implemented and tested according to specifications:
//! 1. [RFC 8891](https://datatracker.ietf.org/doc/html/rfc8891.html) a.k.a **GOST R 34.12-2015**
//! 2. [RFC 5830](https://datatracker.ietf.org/doc/html/rfc5830) a.k.a **GOST 28147-89**
//! 3. Block Cipher Modes: [GOST R 34.13-2015](https://www.tc26.ru/standard/gost/GOST_R_3413-2015.pdf)
//!
//! [Cipher Modes](https://tc26.ru/standard/gost/GOST_R_3413-2015.pdf)
//! * **ECB** - Electronic Codebook Mode
//! * **CTR** - Counter Encryption Mode
//! * **CTR-ACPKM** - Counter Encryption Mode as per [RFC8645](https://www.rfc-editor.org/rfc/rfc8645.html), [P 1323565.1.017— 2018](https://standartgost.ru/g/%D0%A0_1323565.1.017-2018)
//! * **OFB** - Output Feedback Mode
//! * **CBC** - Cipher Block Chaining Mode
//! * **CFB** - Cipher Feedback Mode
//! * **MAC** - Message Authentication Code Generation Mode

pub mod magma;

// re-export the magma core
Expand Down
19 changes: 3 additions & 16 deletions cipher_magma/src/magma.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! **Block Cipher "Magma"**
//! Block Cipher "Magma"
//!
//! Implemented and tested according to specifications:
//! 1. [RFC 8891](https://datatracker.ietf.org/doc/html/rfc8891.html) a.k.a GOST R 34.12-2015
//! 2. [RFC 5830](https://datatracker.ietf.org/doc/html/rfc5830) a.k.a GOST 28147-89
//! 1. [RFC 8891](https://datatracker.ietf.org/doc/html/rfc8891.html) a.k.a **GOST R 34.12-2015**
//! 2. [RFC 5830](https://datatracker.ietf.org/doc/html/rfc5830) a.k.a **GOST 28147-89**
//! 3. Block Cipher Modes: [GOST R 34.13-2015](https://www.tc26.ru/standard/gost/GOST_R_3413-2015.pdf)
//!
//! [Cipher Modes](https://tc26.ru/standard/gost/GOST_R_3413-2015.pdf)
Expand All @@ -14,19 +14,6 @@
//! * **CFB** - Cipher Feedback Mode
//! * **MAC** - Message Authentication Code Generation Mode

/*
RFC 5831: GOST R 34.11-94
hash function:
https://datatracker.ietf.org/doc/rfc5831/
https://datatracker.ietf.org/doc/html/rfc4357
https://en.wikipedia.org/wiki/GOST_(hash_function)
GOST R 34.11-94
GOST 34.311-95
GOST hash function
GOST 28147-89 IMIT
*/

pub mod cipher_mode;
pub mod cipher_operation;
pub mod utils;
Expand Down
24 changes: 13 additions & 11 deletions cipher_magma/src/magma/cipher_mode.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
//! Cipher Mode
//!
//! [Cipher Modes](https://tc26.ru/standard/gost/GOST_R_3413-2015.pdf)
//!
//! * **ECB** - Electronic Codebook Mode
//! * **CTR** - Counter Encryption Mode
//! * **CTR-ACPKM** - Counter Encryption Mode as per [RFC8645](https://www.rfc-editor.org/rfc/rfc8645.html), [P 1323565.1.017— 2018](https://standartgost.ru/g/%D0%A0_1323565.1.017-2018)
//! * **OFB** - Output Feedback Mode
//! * **CBC** - Cipher Block Chaining Mode
//! * **CFB** - Cipher Feedback Mode
//! * **MAC** - Message Authentication Code Generation Mode

pub mod ecb;
pub mod ctr;
pub mod ctr_acpkm;
Expand All @@ -6,17 +18,7 @@ pub mod cbc;
pub mod cfb;
pub mod mac;

/// **Cipher Mode**
///
/// [Cipher Modes](https://tc26.ru/standard/gost/GOST_R_3413-2015.pdf)
///
/// * **ECB** - Electronic Codebook Mode
/// * **CTR** - Counter Encryption Mode
/// * **CTR-ACPKM** - Counter Encryption Mode as per [RFC8645](https://www.rfc-editor.org/rfc/rfc8645.html), [P 1323565.1.017— 2018](https://standartgost.ru/g/%D0%A0_1323565.1.017-2018)
/// * **OFB** - Output Feedback Mode
/// * **CBC** - Cipher Block Chaining Mode
/// * **CFB** - Cipher Feedback Mode
/// * **MAC** - Message Authentication Code Generation Mode
/// Cipher Mode
#[derive(PartialEq, Clone)]
pub enum CipherMode {
/// Electronic Codebook (ECB) Mode
Expand Down
6 changes: 4 additions & 2 deletions cipher_magma/src/magma/cipher_mode/cbc.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
//! Implements Cipher Block Chaining (CBC) mode

use std::collections::VecDeque;

use crate::{magma::Magma, CipherOperation, CipherMode};

/// Returns encrypted result as `Vec<u8>`
///
/// Implements buffer encrypting in Cipher Block Chaining (CBC) Mode
/// Implements buffer encrypting in Cipher Block Chaining (CBC) mode
///
/// [GOST R 34.13-2015](https://www.tc26.ru/standard/gost/GOST_R_3413-2015.pdf)
///
Expand Down Expand Up @@ -42,7 +44,7 @@ pub fn encrypt(core: &mut Magma, buf: &[u8]) -> Vec<u8> {

/// Returns decrypted result as `Vec<u8>`
///
/// Implements buffer decrypting in Cipher Block Chaining (CBC) Mode
/// Implements buffer decrypting in Cipher Block Chaining (CBC) mode
///
/// [GOST R 34.13-2015](https://www.tc26.ru/standard/gost/GOST_R_3413-2015.pdf)
///
Expand Down
6 changes: 4 additions & 2 deletions cipher_magma/src/magma/cipher_mode/cfb.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
//! Implements Cipher Feedback (CFB) mode

use std::collections::VecDeque;

use crate::{magma::Magma, CipherOperation, CipherMode};

/// Returns encrypted result as `Vec<u8>`
///
/// Implements buffer encrypting in Cipher Feedback (CFB) Mode
/// Implements buffer encrypting in Cipher Feedback (CFB) mode
///
/// [GOST R 34.13-2015](https://www.tc26.ru/standard/gost/GOST_R_3413-2015.pdf)
///
Expand Down Expand Up @@ -41,7 +43,7 @@ pub fn encrypt(core: &mut Magma, buf: &[u8]) -> Vec<u8> {

/// Returns decrypted result as `Vec<u8>`
///
/// Implements buffer encrypting in Cipher Feedback (CFB) Mode
/// Implements buffer encrypting in Cipher Feedback (CFB) mode
///
/// [GOST R 34.13-2015](https://www.tc26.ru/standard/gost/GOST_R_3413-2015.pdf)
///
Expand Down
8 changes: 5 additions & 3 deletions cipher_magma/src/magma/cipher_mode/ctr.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
//! Implements Counter Encryption (CTR) mode

use crate::{magma::Magma, CipherOperation, CipherMode};

/// Returns encrypted result as `Vec<u8>`
///
/// Implements buffer encrypting in Counter Encryption (CTR) Mode
/// Implements buffer encrypting in Counter Encryption (CTR) mode
///
/// [GOST R 34.13-2015](https://www.tc26.ru/standard/gost/GOST_R_3413-2015.pdf)
///
Expand All @@ -14,7 +16,7 @@ pub fn encrypt(core: &mut Magma, buf: &[u8]) -> Vec<u8> {

/// Returns decrypted result as `Vec<u8>`
///
/// Implements buffer decrypting in Counter Encryption (CTR) Mode
/// Implements buffer decrypting in Counter Encryption (CTR) mode
///
/// [GOST R 34.13-2015](https://www.tc26.ru/standard/gost/GOST_R_3413-2015.pdf)
///
Expand All @@ -26,7 +28,7 @@ pub fn decrypt(core: &mut Magma, buf: &[u8]) -> Vec<u8> {

/// Returns encrypted/decrypted result as `Vec<u8>`
///
/// Implements Counter Encryption (CTR) Mode
/// Implements the core Counter Encryption (CTR) mode
///
/// [GOST R 34.13-2015](https://www.tc26.ru/standard/gost/GOST_R_3413-2015.pdf)
///
Expand Down
8 changes: 5 additions & 3 deletions cipher_magma/src/magma/cipher_mode/ctr_acpkm.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
//! Implements Counter Encryption (CTR_ACPKM) mode

use crate::magma::{Magma, CipherOperation};
use crate::magma::cipher_mode::CipherMode;

/// Returns encrypted result as `Vec<u8>`
///
/// Implements buffer encrypting in Counter Encryption (CTR_ACPKM) Mode
/// Implements buffer encrypting in Counter Encryption (CTR_ACPKM) mode
///
/// [RFC8645](https://www.rfc-editor.org/rfc/rfc8645.html#section-6.2.2)
///
Expand All @@ -16,7 +18,7 @@ pub fn encrypt(core: &mut Magma, buf: &[u8]) -> Vec<u8> {

/// Returns decrypted result as `Vec<u8>`
///
/// Implements buffer decrypting in Counter Encryption (CTR_ACPKM) Mode
/// Implements buffer decrypting in Counter Encryption (CTR_ACPKM) mode
///
/// [RFC8645](https://www.rfc-editor.org/rfc/rfc8645.html#section-6.2.2)
///
Expand All @@ -29,7 +31,7 @@ pub fn decrypt(core: &mut Magma, buf: &[u8]) -> Vec<u8> {

/// Returns encrypted/decrypted as `Vec<u8>`
///
/// Implements Counter Encryption (CTR_ACPKM) Mode
/// Implements the core of Counter Encryption (CTR_ACPKM) mode
///
/// [RFC8645](https://www.rfc-editor.org/rfc/rfc8645.html#section-6.2.2)
///
Expand Down
8 changes: 5 additions & 3 deletions cipher_magma/src/magma/cipher_mode/ecb.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
//! Implements Electronic Codebook (ECB) mode

use crate::{magma::Magma, CipherOperation, CipherMode};

/// Returns encrypted result as `Vec<u8>`
///
/// Implements buffer encrypting in Electronic Codebook (ECB) Mode
/// Implements buffer encrypting in Electronic Codebook (ECB) mode
///
/// [GOST R 34.13-2015](https://www.tc26.ru/standard/gost/GOST_R_3413-2015.pdf)
///
Expand All @@ -16,7 +18,7 @@ pub fn encrypt(core: &mut Magma, buf: &[u8]) -> Vec<u8> {

/// Returns decrypted result as `Vec<u8>`
///
/// Implements buffer decrypting in Electronic Codebook (ECB) Mode
/// Implements buffer decrypting in Electronic Codebook (ECB) mode
///
/// [GOST R 34.13-2015](https://www.tc26.ru/standard/gost/GOST_R_3413-2015.pdf)
///
Expand All @@ -30,7 +32,7 @@ pub fn decrypt(core: &mut Magma, buf: &[u8]) -> Vec<u8> {

/// Returns encrypted/decrypted result as `Vec<u8>`
///
/// Implements Electronic Codebook (ECB) Mode
/// Implements the core of Electronic Codebook (ECB) mode
///
/// [GOST R 34.13-2015](https://www.tc26.ru/standard/gost/GOST_R_3413-2015.pdf)
///
Expand Down
6 changes: 4 additions & 2 deletions cipher_magma/src/magma/cipher_mode/mac.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
//! Implements Message Authentication Code (MAC)

use crate::{
magma::{utils, Magma},
CipherMode, CipherOperation,
};

/// Returns the Message Authentication Code (MAC) value
/// Returns the Message Authentication Code (MAC)
///
/// # Arguments
/// * core - a mutable reference to `Magma`
Expand Down Expand Up @@ -72,7 +74,7 @@ pub fn update(core: &mut Magma, msg_buf: &[u8]) {
core.context.feedback.block = Some(feedback);
}

/// Finalizes the current context and returns the Message Authentication Code (MAC) value
/// Finalizes the current context and returns the Message Authentication Code (MAC)
///
/// # Arguments
/// * core - a mutable reference to `Magma`
Expand Down
6 changes: 4 additions & 2 deletions cipher_magma/src/magma/cipher_mode/ofb.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Implements Output Feedback (OFB) mode

use std::collections::VecDeque;

use crate::{magma::Magma, CipherOperation, CipherMode};
Expand All @@ -16,7 +18,7 @@ pub fn encrypt(core: &mut Magma, buf: &[u8]) -> Vec<u8> {

/// Returns decrypted result as `Vec<u8>`
///
/// Implements buffer decrypting in Output Feedback (OFB) Mode
/// Implements buffer decrypting in Output Feedback (OFB) mode
///
/// [GOST R 34.13-2015](https://www.tc26.ru/standard/gost/GOST_R_3413-2015.pdf)
///
Expand All @@ -28,7 +30,7 @@ pub fn decrypt(core: &mut Magma, buf: &[u8]) -> Vec<u8> {

/// Returns encrypted/decrypted result as `Vec<u8>`
///
/// Implements Output Feedback (OFB) Mode
/// Implements the core of Output Feedback (OFB) mode
///
/// [GOST R 34.13-2015](https://www.tc26.ru/standard/gost/GOST_R_3413-2015.pdf)
///
Expand Down
2 changes: 1 addition & 1 deletion cipher_magma/src/magma/cipher_operation.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// **Cipher operation**
//! Cipher operation
#[derive(PartialEq, Clone)]
pub enum CipherOperation {
/// Encrypting operation
Expand Down
2 changes: 2 additions & 0 deletions cipher_magma/src/magma/utils.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Utility functions

/// Returns splitted into `(u32, u32)` result
///
/// # Argument
Expand Down

0 comments on commit a6200f2

Please sign in to comment.