dstu_core 0.1.0-x86_64-linux → 0.2.0-x86_64-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2334ab3aa0124cebb58c7581ae4aeb17da063c86cc204c81c4520d2828e31f5
4
- data.tar.gz: ed3fd69afa6c610c3ab0400b57df533d1884a1b7890b87f3cba4dbf3578a4d1f
3
+ metadata.gz: d2f53e978cc8ecfe16e1c2e876e70131e172284a0faacd144e947d62f0f297d1
4
+ data.tar.gz: 530177311f2ba11b2499f0c8154dd182360ebbfa93cfe3210efe49b59bfce36f
5
5
  SHA512:
6
- metadata.gz: 8e1f3bd238c2610b0d49f299d5491da7edcb8c44ad64ec2a1dae830909e5c731e6be51133373179da81ca370e0adbfd7296e23cb0feb4548fe6c15fbcb58886e
7
- data.tar.gz: 8239f6561bb4ab5882b40d75c415cbb45dc6c607d46bb9737fa32dbfc7121a219a6f30d5497d1b3f26eae767cdbd1901f7a77d9b3eb1b1cc48fbdc1d9fac62be
6
+ metadata.gz: d980fe67fb1b9f7e7b4b2a4efc37e3b1064241e194f178eabfcfb758fd6f77abf07e4a2d77f455398084b9a8ef5c1309958df12f147c213d18fa079a6eb41ff5
7
+ data.tar.gz: 3ed1f834b608ad8ddebba72dd5ad012639064e48edd2d82aa1f8526e368f6618b5a94ca2e6b22cc23923bf4e4142e5aa9ecf1d672f5088a4a5b84610493b5bd8
data/README.md CHANGED
@@ -1,11 +1,21 @@
1
1
  # dstu-core (Ruby bindings)
2
2
 
3
- **Provisional — not published to RubyGems, not independently audited.** See the root project's
4
- `docs/SECURITY.md` and `docs/DECISIONS.md` for the full threat model and per-construction status.
5
- This binding wraps the full `dstu_core::crypto_*` surface (`docs/bindings-strategy.md` T-160) —
6
- install from source as shown below.
3
+ **Pre-1.0. Not independently audited.** See the root project's `docs/SECURITY.md` and
4
+ `docs/DECISIONS.md` for the full threat model and per-construction status. This binding wraps the
5
+ full `dstu_core::crypto_*` surface (`docs/bindings-strategy.md` T-160).
7
6
 
8
- ## Installing (from source)
7
+ ## Installing
8
+
9
+ ```sh
10
+ gem install dstu_core
11
+ ```
12
+
13
+ ```ruby
14
+ require "dstu_core"
15
+ DstuCore.self_test
16
+ ```
17
+
18
+ ## Building from source (contributors)
9
19
 
10
20
  ```sh
11
21
  gem install bundler
Binary file
Binary file
Binary file
Binary file
@@ -10,10 +10,11 @@
10
10
  #
11
11
  # **Wire format matches `uacrypt encrypt`/`decrypt` exactly**
12
12
  # (crates/uacrypt/src/lib.rs's `run_secretstream_encrypt`/`run_secretstream_decrypt`, D-68):
13
- # `header (32 bytes)` followed by one record per chunk, `tag_byte (1) || chunk_len_u32_le (4) ||
14
- # ciphertext (chunk_len) || auth_tag (16)`, chunks capped at 8 KiB (matching
15
- # `SECRETSTREAM_CHUNK_BYTES`, not an independent choice) - a file `SecretStreamWriter` writes is
16
- # decryptable by `uacrypt decrypt` and vice versa.
13
+ # `version (1) || header (32 bytes)` followed by one record per chunk, `tag_byte (1) ||
14
+ # chunk_len_u32_le (4) || ciphertext (chunk_len) || auth_tag (16)`. Every record but the Final one is
15
+ # exactly 8 KiB (`SECRETSTREAM_CHUNK_BYTES`, part of the format since D-208, not an independent
16
+ # choice) - a file `SecretStreamWriter` writes is decryptable by `uacrypt decrypt` and vice versa.
17
+ # The shared vectors in crates/dstu-core/tests/vectors/secretstream-file/ pin this.
17
18
  #
18
19
  # **Every `String` this wrapper touches is binary (`ASCII-8BIT`/`BINARY`)**, both what it writes
19
20
  # to `out`/`inp` and what `#read_all`/`#each` yield - matching every underlying `crypto_*` wrapper
@@ -26,6 +27,8 @@ module DstuCore
26
27
  # wire-format interop with `uacrypt encrypt`/`decrypt`, not an independent choice.
27
28
  SECRETSTREAM_CHUNK_BYTES = 8 * 1024
28
29
  SECRETSTREAM_AUTH_TAG_BYTES = 16
30
+ # Matches dstu-core's crypto_secretstream::FORMAT_VERSION (D-208); the shared vectors pin it.
31
+ SECRETSTREAM_FORMAT_VERSION = 2
29
32
 
30
33
  # Write-only wrapper: buffers input and pushes each full 8 KiB chunk to `out` as it fills, hiding
31
34
  # the header/tag/framing bookkeeping entirely.
@@ -38,6 +41,7 @@ module DstuCore
38
41
  @out = out
39
42
  @out.binmode if @out.respond_to?(:binmode)
40
43
  @push = SecretStreamPushState.new(key)
44
+ @out.write([SECRETSTREAM_FORMAT_VERSION].pack("C"))
41
45
  @out.write(@push.header)
42
46
  @buf = +""
43
47
  @closed = false
@@ -115,6 +119,11 @@ module DstuCore
115
119
  def initialize(key, inp)
116
120
  @inp = inp
117
121
  @inp.binmode if @inp.respond_to?(:binmode)
122
+ version = read_exact(1, "format version").unpack1("C")
123
+ if version != SECRETSTREAM_FORMAT_VERSION
124
+ raise DstuCore::Error,
125
+ "unsupported stream format version #{version} (this build reads #{SECRETSTREAM_FORMAT_VERSION})"
126
+ end
118
127
  header = read_exact(32, "header")
119
128
  @pull = SecretStreamPullState.new(key, header)
120
129
  @done = false
@@ -152,6 +161,10 @@ module DstuCore
152
161
  raise DstuCore::Error,
153
162
  "secretstream chunk too large: declared #{chunk_len} bytes, max #{SECRETSTREAM_CHUNK_BYTES}"
154
163
  end
164
+ if tag_byte != SECRETSTREAM_TAG_FINAL && chunk_len != SECRETSTREAM_CHUNK_BYTES
165
+ raise DstuCore::Error,
166
+ "non-final chunk of #{chunk_len} bytes, must be exactly #{SECRETSTREAM_CHUNK_BYTES} (D-208)"
167
+ end
155
168
  ciphertext = read_exact(chunk_len, "chunk ciphertext")
156
169
  auth_tag = read_exact(SECRETSTREAM_AUTH_TAG_BYTES, "chunk auth tag")
157
170
  tag, plaintext = @pull.pull(tag_byte, ciphertext, auth_tag)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DstuCore
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dstu_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - dstu-core contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-08-13 00:00:00.000000000 Z
11
+ date: 2026-10-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby bindings for dstu-core (Ukrainian DSTU cryptographic standards)
14
- - provisional, not yet published to RubyGems.
14
+ - not independently audited.
15
15
  email:
16
16
  executables: []
17
17
  extensions: []