jodid 0.0.4.pre → 0.0.5.pre

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
  SHA1:
3
- metadata.gz: 82df1631d8769d3bef7ff7856e9da393a549df8e
4
- data.tar.gz: 72658ec9fdf9f1145e42aed50177d4e2dae25448
3
+ metadata.gz: 87344c233bb4c05d2c26de1d1c10c8424af0b1da
4
+ data.tar.gz: fb299261fe170fa93b4b21d5bddb3a4b612818b2
5
5
  SHA512:
6
- metadata.gz: 0eab9496874fb4693fced13d0215cd66104ae5450a69075e887bb960228f8cec642e7d704682c8a29fefa75d6143540161511d41be7264800e5c8feab3927879
7
- data.tar.gz: e952b53e8ea2e9344ba75a964b88ba2c083fcd47609e918b675c7795d167559dd312983feca7753f9cd29a9c62fc84cd3a20839ef290c6b4a602ff87c35481f4
6
+ metadata.gz: a96313b68b973a071c97094367990f91c1535f2b4a1865337e7f226eb001bb83bb824ef31a034a35e6479fcae70f2b395d92ffcc0facd73478233b300216bf91
7
+ data.tar.gz: bf4bda8581cd0d25faa5bb5677c0ae4b0032214b852187600d42fd688890fde58d2d2fcd6665501848276e56d75442019442f0342bdad7e8ee40f62d94800d0e
@@ -20,14 +20,18 @@ module Jodid
20
20
  salt = Crypto::PwHash::ScryptSalsa208SHA256.salt
21
21
  key = Crypto::PwHash::ScryptSalsa208SHA256.scryptsalsa208sha256(
22
22
  Crypto::OneTimeAuth::KEYBYTES, password, salt)
23
- mac = Crypto::OneTimeAuth.onetimeauth(password, key)
24
-
25
- public_key, secret_key = Crypto::Sign.memory_locked_seed_keypair(key)
23
+ nonce = Crypto::AEAD::Chacha20Poly1305.nonce
24
+ seed = RandomBytes.buf(Crypto::Sign::SEEDBYTES)
25
+ ciphertext = Crypto::AEAD::Chacha20Poly1305.encrypt(seed, identity, nonce, key)
26
+ pk, sk = Crypto::Sign.memory_locked_seed_keypair(seed)
27
+ Sodium.memzero(seed, Crypto::Sign::SEEDBYTES)
26
28
  @storage.store(identity, :salt, salt)
27
- store_public_key(identity, public_key)
28
- @storage.store(identity, :mac, mac)
29
- Base64.strict_encode64 public_key
29
+ @storage.store(identity, :nonce, nonce)
30
+ @storage.store(identity, :ciphertext, ciphertext)
31
+ store_public_key(identity, pk)
32
+ Base64.strict_encode64(pk)
30
33
  ensure
34
+ Sodium.memzero(password, password.bytesize)
31
35
  password.clear
32
36
  end
33
37
 
@@ -35,13 +39,14 @@ module Jodid
35
39
  key = Crypto::PwHash::ScryptSalsa208SHA256.scryptsalsa208sha256(
36
40
  Crypto::OneTimeAuth::KEYBYTES, password,
37
41
  @storage.fetch(identity, :salt))
38
-
39
- if Crypto::OneTimeAuth.verify(@storage.fetch(identity, :mac),
40
- password, key)
41
-
42
- Cryptor.new(*Crypto::Sign.memory_locked_seed_keypair(key), self)
43
- end
42
+ seed = Crypto::AEAD::Chacha20Poly1305.decrypt(
43
+ @storage.fetch(identity, :ciphertext),
44
+ identity, @storage.fetch(identity, :nonce), key)
45
+ cryptor = Cryptor.new(*Crypto::Sign.memory_locked_seed_keypair(seed), self)
46
+ Sodium.memzero(seed, Crypto::Sign::SEEDBYTES)
47
+ cryptor
44
48
  ensure
49
+ Sodium.memzero(password, password.bytesize)
45
50
  password.clear
46
51
  end
47
52
 
data/lib/jodid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Jodid
2
- VERSION = Gem::Version.new('0.0.4.pre')
2
+ VERSION = Gem::Version.new('0.0.5.pre')
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jodid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.pre
4
+ version: 0.0.5.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hendrik Beskow