windows-cng 0.0.1
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 +7 -0
- data/CHANGES +2 -0
- data/MANIFEST +8 -0
- data/README +32 -0
- data/Rakefile +38 -0
- data/lib/windows/cng.rb +168 -0
- data/lib/windows/cng/constants.rb +55 -0
- data/lib/windows/cng/functions.rb +146 -0
- data/lib/windows/cng/helper.rb +14 -0
- data/lib/windows/cng/structs.rb +4 -0
- data/test/test_windows_cng.rb +16 -0
- data/windows-cng.gemspec +25 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 81743d0ede2937d8627b6f830d807462eb580083
|
4
|
+
data.tar.gz: 62dcf2ea25fa18cba23315f6ebacbde279d44413
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c35b7b5dba655aeea93616b8d05072e7319d60cb72441a819a733b8f6cadc97da4bf25466e71f73c24ab37068df78fd2ddd54020460384017aea2967a2d5739f
|
7
|
+
data.tar.gz: 9df2e81e27a3a2d8870113da5cc355ebc8f235758a314b78064cd70548e9460e274855dfc29aebd9c7c4f7d1ed112fb3e28c1452fe263bfe97a6f7dcdb197105
|
data/CHANGES
ADDED
data/MANIFEST
ADDED
data/README
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
= Description
|
2
|
+
An interface for the Windows Next Generation Cryptography library.
|
3
|
+
|
4
|
+
= Installation
|
5
|
+
gem install windows-cng
|
6
|
+
|
7
|
+
= Synopsis
|
8
|
+
require 'windows/cng'
|
9
|
+
|
10
|
+
cng = Windows::CNG.new
|
11
|
+
cng.hash('some string')
|
12
|
+
cng.close
|
13
|
+
|
14
|
+
= License
|
15
|
+
Artistic 2.0
|
16
|
+
|
17
|
+
= Contributions
|
18
|
+
Although this library is free, please consider having your company
|
19
|
+
setup a gittip if used by your company professionally.
|
20
|
+
|
21
|
+
http://www.gittip.com/djberg96/
|
22
|
+
|
23
|
+
= Copyright
|
24
|
+
(C) 2014 Daniel J. Berger, All Rights Reserved
|
25
|
+
|
26
|
+
= Warranty
|
27
|
+
This package is provided "as is" and without any express or
|
28
|
+
implied warranties, including, without limitation, the implied
|
29
|
+
warranties of merchantability and fitness for a particular purpose.
|
30
|
+
|
31
|
+
= Author
|
32
|
+
Daniel J. Berger
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rake/testtask'
|
4
|
+
|
5
|
+
CLEAN.include('**/*.gem', '**/*.log')
|
6
|
+
|
7
|
+
namespace 'gem' do
|
8
|
+
desc "Create the windows-cng gem"
|
9
|
+
task :create => [:clean] do
|
10
|
+
Dir["*.gem"].each{ |f| File.delete(f) }
|
11
|
+
spec = eval(IO.read('windows-cng.gemspec'))
|
12
|
+
|
13
|
+
if Gem::VERSION < "2.0"
|
14
|
+
Gem::Builder.new(spec).build
|
15
|
+
else
|
16
|
+
require 'rubygems/package'
|
17
|
+
Gem::Package.build(spec)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Install the windows-cng gem"
|
22
|
+
task :install => [:create] do
|
23
|
+
file = Dir["*.gem"].first
|
24
|
+
sh "gem install -l #{file}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Run the example program"
|
29
|
+
task :example do
|
30
|
+
sh "ruby -Ilib examples/dir_example.rb"
|
31
|
+
end
|
32
|
+
|
33
|
+
Rake::TestTask.new do |t|
|
34
|
+
t.warning = true
|
35
|
+
t.verbose = true
|
36
|
+
end
|
37
|
+
|
38
|
+
task :default => :test
|
data/lib/windows/cng.rb
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
require_relative 'cng/constants'
|
2
|
+
require_relative 'cng/functions'
|
3
|
+
require_relative 'cng/structs'
|
4
|
+
require_relative 'cng/helper'
|
5
|
+
|
6
|
+
module Windows
|
7
|
+
class CNG
|
8
|
+
include Windows::CNGConstants
|
9
|
+
include Windows::CNGFunctions
|
10
|
+
include Windows::MiscFunctions
|
11
|
+
include Windows::CNGStructs
|
12
|
+
include Windows::CNGHelper
|
13
|
+
|
14
|
+
# The version of the windows-cng library.
|
15
|
+
VERSION = '0.0.1'
|
16
|
+
|
17
|
+
# Creates and returns a new Windows::CNG object.
|
18
|
+
#
|
19
|
+
# The +algorithm+ argument specifies the type of algorithm to use for the
|
20
|
+
# various crypto methods. The default is SHA256.
|
21
|
+
#
|
22
|
+
# The +implementation+ identifies the specific provider to load. This is
|
23
|
+
# the registered alias of the cryptographic primitive provider. By default
|
24
|
+
# this is nil.
|
25
|
+
#
|
26
|
+
# The flags argument can be one or more of the following values:
|
27
|
+
#
|
28
|
+
# * BCRYPT_ALG_HANDLE_HMAC_FLAG
|
29
|
+
# * BCRYPT_PROV_DISPATCH
|
30
|
+
# * BCRYPT_HASH_REUSABLE_FLAG
|
31
|
+
#
|
32
|
+
# See the MSDN documentation for details of what each flag does.
|
33
|
+
#
|
34
|
+
def initialize(algorithm = BCRYPT_SHA256_ALGORITHM, implementation = nil, flags = 0)
|
35
|
+
@algorithm = algorithm.wincode
|
36
|
+
@implementation = implementation ? implementation.wincode : implementation
|
37
|
+
@flags = flags
|
38
|
+
|
39
|
+
ptr = FFI::MemoryPointer.new(:pointer)
|
40
|
+
|
41
|
+
status = BCryptOpenAlgorithmProvider(
|
42
|
+
ptr,
|
43
|
+
@algorithm,
|
44
|
+
@implementation,
|
45
|
+
@flags
|
46
|
+
)
|
47
|
+
|
48
|
+
if status != 0
|
49
|
+
raise SystemCallError.new('BCryptOpenAlgorithmProvider', status)
|
50
|
+
end
|
51
|
+
|
52
|
+
@handle = ptr.read_pointer
|
53
|
+
|
54
|
+
ObjectSpace.define_finalizer(self, self.class.finalize(@handle))
|
55
|
+
end
|
56
|
+
|
57
|
+
# Returns a hash of +data+ using the algorithm used in the constructor.
|
58
|
+
#
|
59
|
+
def hash(data)
|
60
|
+
cbhash_object = FFI::MemoryPointer.new(:ulong)
|
61
|
+
cbdata = FFI::MemoryPointer.new(:ulong)
|
62
|
+
|
63
|
+
status = BCryptGetProperty(
|
64
|
+
@handle,
|
65
|
+
BCRYPT_OBJECT_LENGTH.wincode,
|
66
|
+
cbhash_object,
|
67
|
+
cbhash_object.size,
|
68
|
+
cbdata,
|
69
|
+
0
|
70
|
+
)
|
71
|
+
|
72
|
+
if status != 0
|
73
|
+
raise SystemCallError.new('BCryptGetProperty', status)
|
74
|
+
end
|
75
|
+
|
76
|
+
begin
|
77
|
+
pbhash_object = HeapAlloc(GetProcessHeap(), 0, cbhash_object.read_ulong)
|
78
|
+
|
79
|
+
if pbhash_object.null?
|
80
|
+
raise SystemCallError.new('HeapAlloc', FFI.errno)
|
81
|
+
end
|
82
|
+
|
83
|
+
cbhash = FFI::MemoryPointer.new(:ulong)
|
84
|
+
cbdata.clear
|
85
|
+
|
86
|
+
status = BCryptGetProperty(
|
87
|
+
@handle,
|
88
|
+
BCRYPT_HASH_LENGTH.wincode,
|
89
|
+
cbhash,
|
90
|
+
cbhash.size,
|
91
|
+
cbdata,
|
92
|
+
0
|
93
|
+
)
|
94
|
+
|
95
|
+
if status != 0
|
96
|
+
raise SystemCallError.new('BCryptGetProperty', status)
|
97
|
+
end
|
98
|
+
|
99
|
+
cbhash = cbhash.read_ulong
|
100
|
+
pbhash = HeapAlloc(GetProcessHeap(), 0, cbhash)
|
101
|
+
|
102
|
+
if pbhash.null?
|
103
|
+
raise SystemCallError.new('HeapAlloc', FFI.errno)
|
104
|
+
end
|
105
|
+
|
106
|
+
ptr = FFI::MemoryPointer.new(:pointer)
|
107
|
+
|
108
|
+
status = BCryptCreateHash(
|
109
|
+
@handle,
|
110
|
+
ptr,
|
111
|
+
pbhash_object,
|
112
|
+
cbhash_object.read_ulong,
|
113
|
+
nil,
|
114
|
+
0,
|
115
|
+
0
|
116
|
+
)
|
117
|
+
|
118
|
+
if status != 0
|
119
|
+
raise SystemCallError.new('BCryptCreateHash', status)
|
120
|
+
end
|
121
|
+
|
122
|
+
hhash = ptr.read_pointer
|
123
|
+
|
124
|
+
status = BCryptHashData(hhash, data, data.size, 0)
|
125
|
+
|
126
|
+
if status != 0
|
127
|
+
raise SystemCallError.new('BCryptHashData', status)
|
128
|
+
end
|
129
|
+
|
130
|
+
status = BCryptFinishHash(hhash, pbhash, cbhash, 0)
|
131
|
+
|
132
|
+
if status != 0
|
133
|
+
raise SystemCallError.new('BCryptFinishHash', status)
|
134
|
+
end
|
135
|
+
|
136
|
+
pbhash.read_bytes(cbhash)
|
137
|
+
ensure
|
138
|
+
if pbhash_object && !pbhash_object.null?
|
139
|
+
HeapFree(GetProcessHeap(), 0, pbhash_object)
|
140
|
+
end
|
141
|
+
|
142
|
+
if pbhash && !pbhash.null?
|
143
|
+
HeapFree(GetProcessHeap(), 0, pbhash)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
# Closes the windows-cng object. This is not explicitly required, since
|
149
|
+
# it will automatically be called once your object goes out of scope, but
|
150
|
+
# it is good form.
|
151
|
+
#
|
152
|
+
def close
|
153
|
+
status = BCryptCloseAlgorithmProvider(@handle, 0)
|
154
|
+
|
155
|
+
if status != 0
|
156
|
+
raise SystemCallError.new('BCryptCloseAlgorithmProvider', status)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
private
|
161
|
+
|
162
|
+
# Automatically close crypto object when it goes out of scope.
|
163
|
+
#
|
164
|
+
def self.finalize(handle)
|
165
|
+
proc{ BCryptCloseAlgorithmProvider(handle, 0) }
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Windows
|
2
|
+
module CNGConstants
|
3
|
+
# NTSTATUS values
|
4
|
+
STATUS_SUCCESS = 0x00000000
|
5
|
+
STATUS_SEVERITY_SUCCESS = 0x00000000
|
6
|
+
STATUS_SEVERITY_INFORMATIONAL = 0x00000001
|
7
|
+
STATUS_SEVERITY_WARNING = 0x00000002
|
8
|
+
STATUS_SEVERITY_ERROR = 0x00000003
|
9
|
+
|
10
|
+
# CNG Algorithm Identifiers
|
11
|
+
BCRYPT_3DES_ALGORITHM = "3DES"
|
12
|
+
BCRYPT_3DES_112_ALGORITHM = "3DES_112"
|
13
|
+
BCRYPT_AES_ALGORITHM = "AES"
|
14
|
+
BCRYPT_AES_CMAC_ALGORITHM = "AES-CMAC"
|
15
|
+
BCRYPT_AES_GMAC_ALGORITHM = "AES-GMAC"
|
16
|
+
BCRYPT_CAPI_KDF_ALGORITHM = "CAPI_KDF"
|
17
|
+
BCRYPT_DES_ALGORITHM = "DES"
|
18
|
+
BCRYPT_DESX_ALGORITHM = "DESX"
|
19
|
+
BCRYPT_DH_ALGORITHM = "DH"
|
20
|
+
BCRYPT_DSA_ALGORITHM = "DSA"
|
21
|
+
BCRYPT_ECDH_P256_ALGORITHM = "ECDH_P256"
|
22
|
+
BCRYPT_ECDH_P384_ALGORITHM = "ECDH_P384"
|
23
|
+
BCRYPT_ECDH_P521_ALGORITHM = "ECDH_P521"
|
24
|
+
BCRYPT_ECDSA_P256_ALGORITHM = "ECDSA_P256"
|
25
|
+
BCRYPT_ECDSA_P384_ALGORITHM = "ECDSA_P384"
|
26
|
+
BCRYPT_ECDSA_P521_ALGORITHM = "ECDSA_P521"
|
27
|
+
BCRYPT_MD2_ALGORITHM = "MD2"
|
28
|
+
BCRYPT_MD4_ALGORITHM = "MD4"
|
29
|
+
BCRYPT_MD5_ALGORITHM = "MD5"
|
30
|
+
BCRYPT_RC2_ALGORITHM = "RC2"
|
31
|
+
BCRYPT_RC4_ALGORITHM = "RC4"
|
32
|
+
BCRYPT_RNG_ALGORITHM = "RNG"
|
33
|
+
BCRYPT_RNG_DUAL_EC_ALGORITHM = "DUALECRNG"
|
34
|
+
BCRYPT_RNG_FIPS186_DSA_ALGORITHM = "FIPS186DSARNG"
|
35
|
+
BCRYPT_RSA_ALGORITHM = "RSA"
|
36
|
+
BCRYPT_RSA_SIGN_ALGORITHM = "RSA_SIGN"
|
37
|
+
BCRYPT_SHA1_ALGORITHM = "SHA1"
|
38
|
+
BCRYPT_SHA256_ALGORITHM = "SHA256"
|
39
|
+
BCRYPT_SHA384_ALGORITHM = "SHA384"
|
40
|
+
BCRYPT_SHA512_ALGORITHM = "SHA512"
|
41
|
+
BCRYPT_SP800108_CTR_HMAC_ALGORITHM = "SP800_108_CTR_HMAC"
|
42
|
+
BCRYPT_SP80056A_CONCAT_ALGORITHM = "SP800_56A_CONCAT"
|
43
|
+
BCRYPT_PBKDF2_ALGORITHM = "PBKDF2"
|
44
|
+
|
45
|
+
# Primitive Property Identifiers. Encode as necessary.
|
46
|
+
BCRYPT_ALGORITHM_NAME = "AlgorithmName"
|
47
|
+
BCRYPT_AUTH_TAG_LENGTH = "AuthTagLength"
|
48
|
+
BCRYPT_BLOCK_LENGTH = "BlockLength"
|
49
|
+
BCRYPT_OBJECT_LENGTH = "ObjectLength"
|
50
|
+
BCRYPT_BLOCK_SIZE_LIST = "BlockSizeList"
|
51
|
+
BCRYPT_CHAINING_MODE = "ChainingMode"
|
52
|
+
BCRYPT_HASH_BLOCK_LENGTH = "HashBlockLength"
|
53
|
+
BCRYPT_HASH_LENGTH = "HashDigestLength"
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
|
3
|
+
module Windows
|
4
|
+
module MiscFunctions
|
5
|
+
extend FFI::Library
|
6
|
+
ffi_lib :kernel32
|
7
|
+
|
8
|
+
typedef :uintptr_t, :handle
|
9
|
+
typedef :ulong, :dword
|
10
|
+
|
11
|
+
attach_function :HeapAlloc, [:handle, :dword, :size_t], :pointer
|
12
|
+
attach_function :HeapFree, [:handle, :dword, :pointer], :bool
|
13
|
+
attach_function :GetProcessHeap, [], :handle
|
14
|
+
end
|
15
|
+
|
16
|
+
module SSLProviderFunctions
|
17
|
+
end
|
18
|
+
|
19
|
+
module KeyStorageFunctions
|
20
|
+
end
|
21
|
+
|
22
|
+
module HelperFunctions
|
23
|
+
end
|
24
|
+
|
25
|
+
module DPAPIFunctions
|
26
|
+
extend FFI::Library
|
27
|
+
ffi_lib :ncrypt
|
28
|
+
|
29
|
+
typedef :uintptr_t, :handle
|
30
|
+
typedef :ulong, :ntstatus
|
31
|
+
typedef :ulong, :dword
|
32
|
+
|
33
|
+
# CNG Data Protection API Functions - Windows 8 or later
|
34
|
+
|
35
|
+
#attach_function :NCryptCreateProtectionDescriptor, [:buffer_in, :dword, :pointer], :ntstatus
|
36
|
+
#attach_function :NCryptCloseProtectionDescriptor
|
37
|
+
#attach_function :NCryptGetProtectionDescriptorInfo
|
38
|
+
#attach_function :NCryptProtectSecret
|
39
|
+
#attach_function :NCryptQueryProtectionDescriptorName
|
40
|
+
#attach_function :NCryptRegisterProtectionDescriptorName
|
41
|
+
#attach_function :NCryptStreamClose
|
42
|
+
#attach_function :NCryptStreamOpenToProtect
|
43
|
+
#attach_function :NCryptStreamOpenToUnProtect
|
44
|
+
#attach_function :NCryptStreamUpdate
|
45
|
+
#attach_function :NCryptUnprotectSecret
|
46
|
+
#attach_function :PFNCryptStreamOutputCallback
|
47
|
+
end
|
48
|
+
|
49
|
+
module CNGFunctions
|
50
|
+
extend FFI::Library
|
51
|
+
ffi_lib :bcrypt
|
52
|
+
|
53
|
+
typedef :long, :ntstatus
|
54
|
+
|
55
|
+
## CNG Cryptographic Primitive Functions
|
56
|
+
|
57
|
+
attach_function :BCryptCloseAlgorithmProvider,
|
58
|
+
[:pointer, :ulong],
|
59
|
+
:ntstatus
|
60
|
+
|
61
|
+
attach_function :BCryptCreateHash,
|
62
|
+
[:pointer, :pointer, :pointer, :ulong, :pointer, :ulong, :ulong],
|
63
|
+
:ntstatus
|
64
|
+
|
65
|
+
attach_function :BCryptDecrypt,
|
66
|
+
[:pointer, :pointer, :ulong, :pointer, :pointer, :ulong, :pointer, :ulong, :ulong, :ulong],
|
67
|
+
:ntstatus
|
68
|
+
|
69
|
+
attach_function :BCryptDeriveKey,
|
70
|
+
[:pointer, :string, :pointer, :pointer, :ulong, :ulong, :ulong],
|
71
|
+
:ntstatus
|
72
|
+
|
73
|
+
attach_function :BCryptDestroyHash, [:pointer], :ntstatus
|
74
|
+
attach_function :BCryptDestroyKey, [:pointer], :ntstatus
|
75
|
+
attach_function :BCryptDestroySecret, [:pointer], :ntstatus
|
76
|
+
|
77
|
+
attach_function :BCryptDuplicateHash,
|
78
|
+
[:pointer, :pointer, :pointer, :ulong, :ulong],
|
79
|
+
:ntstatus
|
80
|
+
|
81
|
+
attach_function :BCryptDuplicateKey,
|
82
|
+
[:pointer, :pointer, :pointer, :ulong, :ulong],
|
83
|
+
:ntstatus
|
84
|
+
|
85
|
+
attach_function :BCryptEncrypt,
|
86
|
+
[:pointer, :pointer, :ulong, :pointer, :pointer, :ulong, :pointer, :ulong, :ulong, :ulong],
|
87
|
+
:ntstatus
|
88
|
+
|
89
|
+
attach_function :BCryptExportKey,
|
90
|
+
[:pointer, :pointer, :string, :pointer, :ulong, :ulong, :ulong],
|
91
|
+
:ntstatus
|
92
|
+
|
93
|
+
attach_function :BCryptFinalizeKeyPair, [:pointer, :ulong], :ntstatus
|
94
|
+
attach_function :BCryptFinishHash, [:pointer, :pointer, :ulong, :ulong], :ntstatus
|
95
|
+
attach_function :BCryptFreeBuffer, [:pointer], :void
|
96
|
+
attach_function :BCryptGenerateKeyPair, [:pointer, :pointer, :ulong, :ulong], :ntstatus
|
97
|
+
|
98
|
+
attach_function :BCryptGenerateSymmetricKey,
|
99
|
+
[:pointer, :pointer, :pointer, :ulong, :pointer, :ulong, :ulong],
|
100
|
+
:ntstatus
|
101
|
+
|
102
|
+
attach_function :BCryptGenRandom, [:pointer, :pointer, :ulong, :ulong], :ntstatus
|
103
|
+
|
104
|
+
attach_function :BCryptGetProperty,
|
105
|
+
[:pointer, :buffer_in, :pointer, :ulong, :pointer, :ulong],
|
106
|
+
:ntstatus
|
107
|
+
|
108
|
+
attach_function :BCryptHashData, [:pointer, :pointer, :ulong, :ulong], :ntstatus
|
109
|
+
|
110
|
+
attach_function :BCryptImportKey,
|
111
|
+
[:pointer, :pointer, :string, :pointer, :pointer, :ulong, :pointer, :ulong, :ulong],
|
112
|
+
:ntstatus
|
113
|
+
|
114
|
+
attach_function :BCryptImportKeyPair,
|
115
|
+
[:pointer, :pointer, :string, :pointer, :pointer, :ulong, :ulong],
|
116
|
+
:ntstatus
|
117
|
+
|
118
|
+
attach_function :BCryptOpenAlgorithmProvider,
|
119
|
+
[:pointer, :buffer_in, :buffer_in, :ulong],
|
120
|
+
:ntstatus
|
121
|
+
|
122
|
+
attach_function :BCryptSecretAgreement,
|
123
|
+
[:pointer, :pointer, :pointer, :ulong],
|
124
|
+
:ntstatus
|
125
|
+
|
126
|
+
attach_function :BCryptSetProperty,
|
127
|
+
[:pointer, :string, :pointer, :ulong, :ulong],
|
128
|
+
:ntstatus
|
129
|
+
|
130
|
+
attach_function :BCryptSignHash,
|
131
|
+
[:pointer, :pointer, :pointer, :ulong, :pointer, :ulong, :pointer, :ulong],
|
132
|
+
:ntstatus
|
133
|
+
|
134
|
+
attach_function :BCryptVerifySignature,
|
135
|
+
[:pointer, :pointer, :pointer, :ulong, :pointer, :ulong, :ulong],
|
136
|
+
:ntstatus
|
137
|
+
|
138
|
+
begin
|
139
|
+
attach_function :BCryptKeyDerivation,
|
140
|
+
[:pointer, :pointer, :pointer, :ulong, :pointer, :ulong],
|
141
|
+
:ntstatus
|
142
|
+
rescue FFI::NotFoundError
|
143
|
+
# Windows 8 or later
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Windows
|
2
|
+
module CNGHelper
|
3
|
+
end
|
4
|
+
end
|
5
|
+
|
6
|
+
class String
|
7
|
+
unless instance_methods.include?(:wincode)
|
8
|
+
# Convenience method for converting strings to UTF-16LE for wide character
|
9
|
+
# functions that require it.
|
10
|
+
def wincode
|
11
|
+
(self.tr(File::SEPARATOR, File::ALT_SEPARATOR) + 0.chr).encode('UTF-16LE')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'test-unit'
|
2
|
+
require 'windows/cng'
|
3
|
+
|
4
|
+
class TC_Windows_CNG < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@cng = Windows::CNG.new
|
7
|
+
end
|
8
|
+
|
9
|
+
test "version number is set to correct value" do
|
10
|
+
assert_equal("0.0.1", Windows::CNG::VERSION)
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
@cng.close
|
15
|
+
end
|
16
|
+
end
|
data/windows-cng.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'windows-cng'
|
5
|
+
spec.version = '0.0.1'
|
6
|
+
spec.author = 'Daniel J. Berger'
|
7
|
+
spec.license = 'Artistic 2.0'
|
8
|
+
spec.email = 'djberg96@gmail.com'
|
9
|
+
spec.homepage = 'http://github.com/djberg96/windows-cng'
|
10
|
+
spec.summary = 'A Ruby interface to the next gen Windows crypto library'
|
11
|
+
spec.test_file = 'test/test_windows_cng.rb'
|
12
|
+
spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
|
13
|
+
|
14
|
+
spec.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
|
15
|
+
|
16
|
+
spec.add_dependency('ffi')
|
17
|
+
|
18
|
+
spec.add_development_dependency('rake')
|
19
|
+
spec.add_development_dependency('test-unit')
|
20
|
+
|
21
|
+
spec.description = <<-EOF
|
22
|
+
The windows-cng library is a wrapper for the next generation Windows
|
23
|
+
cryptography API.
|
24
|
+
EOF
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: windows-cng
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel J. Berger
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ffi
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: |2
|
56
|
+
The windows-cng library is a wrapper for the next generation Windows
|
57
|
+
cryptography API.
|
58
|
+
email: djberg96@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files:
|
62
|
+
- README
|
63
|
+
- CHANGES
|
64
|
+
- MANIFEST
|
65
|
+
files:
|
66
|
+
- CHANGES
|
67
|
+
- MANIFEST
|
68
|
+
- README
|
69
|
+
- Rakefile
|
70
|
+
- lib/windows/cng.rb
|
71
|
+
- lib/windows/cng/constants.rb
|
72
|
+
- lib/windows/cng/functions.rb
|
73
|
+
- lib/windows/cng/helper.rb
|
74
|
+
- lib/windows/cng/structs.rb
|
75
|
+
- test/test_windows_cng.rb
|
76
|
+
- windows-cng.gemspec
|
77
|
+
homepage: http://github.com/djberg96/windows-cng
|
78
|
+
licenses:
|
79
|
+
- Artistic 2.0
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.2.2
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: A Ruby interface to the next gen Windows crypto library
|
101
|
+
test_files:
|
102
|
+
- test/test_windows_cng.rb
|