dukpt 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/dukpt/decrypter.rb +12 -0
- data/lib/dukpt/version.rb +1 -1
- data/test/decrypter_test.rb +11 -0
- metadata +8 -10
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3bca5288bcff81b55d59ae8421925e7c99e6b30f
|
4
|
+
data.tar.gz: 36d53c531ed1b0d25aa4252e3c601a9f15660cae
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 366979966978f13c5866ac6d987d92bf267c4e82fd795bf19876a40c85c654e1118d68ff600b709ac4721b0cdb64f425580fbfa6f0d84b2d88a3a9fb8af30e0d
|
7
|
+
data.tar.gz: a5b23896a45fde35f3efcca58572552d8af120acdb618a73f428780595dbc40e761d404357c5394daeb2e9f29c2ebe162b0ed2d7b3e44f4be62dd61cc7bf7fe5
|
data/lib/dukpt/decrypter.rb
CHANGED
@@ -15,5 +15,17 @@ module DUKPT
|
|
15
15
|
decrypted_cryptogram = triple_des_decrypt(pek, cryptogram)
|
16
16
|
[decrypted_cryptogram].pack('H*')
|
17
17
|
end
|
18
|
+
|
19
|
+
def decrypt_pin_block(cryptogram, ksn)
|
20
|
+
decrypt(cryptogram, ksn)
|
21
|
+
end
|
22
|
+
|
23
|
+
def decrypt_data_block(cryptogram, ksn)
|
24
|
+
ipek = derive_IPEK(bdk, ksn)
|
25
|
+
dek = derive_DEK(ipek, ksn)
|
26
|
+
decrypted_cryptogram = triple_des_decrypt(dek, cryptogram)
|
27
|
+
[decrypted_cryptogram].pack('H*')
|
28
|
+
end
|
29
|
+
|
18
30
|
end
|
19
31
|
end
|
data/lib/dukpt/version.rb
CHANGED
data/test/decrypter_test.rb
CHANGED
@@ -12,6 +12,17 @@ class DUKPT::DecrypterTest < Test::Unit::TestCase
|
|
12
12
|
|
13
13
|
decrypter = DUKPT::Decrypter.new(bdk, "cbc")
|
14
14
|
assert_equal plaintext, decrypter.decrypt(ciphertext, ksn)
|
15
|
+
assert_equal plaintext, decrypter.decrypt_pin_block(ciphertext, ksn)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_decrypt_data_block
|
19
|
+
bdk = "0123456789ABCDEFFEDCBA9876543210"
|
20
|
+
ksn = "FFFF01040DA058E00001"
|
21
|
+
ciphertext = "85A8A7F9390FD19EABC40B5D624190287D729923D9EDAFE9F24773388A9A1BEF"
|
22
|
+
plaintext = ["5A08476173900101001057114761739001010010D15122011143878089000000"].pack("H*")
|
23
|
+
|
24
|
+
decrypter = DUKPT::Decrypter.new(bdk, "cbc")
|
25
|
+
assert_equal plaintext, decrypter.decrypt_data_block(ciphertext, ksn)
|
15
26
|
end
|
16
27
|
|
17
28
|
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dukpt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- David Seal
|
@@ -10,7 +9,7 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2014-11-05 00:00:00.000000000 Z
|
14
13
|
dependencies: []
|
15
14
|
description: Implements a Derived Unique Key Per Transaction (DUKPT) decrypter
|
16
15
|
email:
|
@@ -20,7 +19,7 @@ executables: []
|
|
20
19
|
extensions: []
|
21
20
|
extra_rdoc_files: []
|
22
21
|
files:
|
23
|
-
- .gitignore
|
22
|
+
- ".gitignore"
|
24
23
|
- Gemfile
|
25
24
|
- LICENSE
|
26
25
|
- README.md
|
@@ -34,27 +33,26 @@ files:
|
|
34
33
|
- test/encryption_test.rb
|
35
34
|
homepage: ''
|
36
35
|
licenses: []
|
36
|
+
metadata: {}
|
37
37
|
post_install_message:
|
38
38
|
rdoc_options: []
|
39
39
|
require_paths:
|
40
40
|
- lib
|
41
41
|
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
42
|
requirements:
|
44
|
-
- -
|
43
|
+
- - ">="
|
45
44
|
- !ruby/object:Gem::Version
|
46
45
|
version: '0'
|
47
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
-
none: false
|
49
47
|
requirements:
|
50
|
-
- -
|
48
|
+
- - ">="
|
51
49
|
- !ruby/object:Gem::Version
|
52
50
|
version: '0'
|
53
51
|
requirements: []
|
54
52
|
rubyforge_project:
|
55
|
-
rubygems_version:
|
53
|
+
rubygems_version: 2.2.2
|
56
54
|
signing_key:
|
57
|
-
specification_version:
|
55
|
+
specification_version: 4
|
58
56
|
summary: Implements a Derived Unique Key Per Transaction (DUKPT) decrypter
|
59
57
|
test_files:
|
60
58
|
- test/decrypter_test.rb
|