virgil-sdk 4.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/.DS_Store +0 -0
  3. data/.gitignore +15 -0
  4. data/Gemfile +4 -0
  5. data/README.md +134 -0
  6. data/Rakefile +9 -0
  7. data/bin/console +16 -0
  8. data/bin/setup +8 -0
  9. data/dockefiles/Dockerfile-200 +25 -0
  10. data/dockefiles/Dockerfile-2110 +36 -0
  11. data/dockefiles/Dockerfile-220 +26 -0
  12. data/dockefiles/Dockerfile-226 +25 -0
  13. data/dockefiles/Dockerfile-233 +25 -0
  14. data/dockefiles/Dockerfile-240 +26 -0
  15. data/docker-compose.yml +107 -0
  16. data/lib/virgil/sdk.rb +10 -0
  17. data/lib/virgil/sdk/client.rb +47 -0
  18. data/lib/virgil/sdk/client/card.rb +142 -0
  19. data/lib/virgil/sdk/client/card_validator.rb +104 -0
  20. data/lib/virgil/sdk/client/http.rb +45 -0
  21. data/lib/virgil/sdk/client/http/base_connection.rb +112 -0
  22. data/lib/virgil/sdk/client/http/cards_service_connection.rb +113 -0
  23. data/lib/virgil/sdk/client/http/request.rb +63 -0
  24. data/lib/virgil/sdk/client/request_signer.rb +90 -0
  25. data/lib/virgil/sdk/client/requests.rb +50 -0
  26. data/lib/virgil/sdk/client/requests/confirm_identity_request.rb +67 -0
  27. data/lib/virgil/sdk/client/requests/create_card_request.rb +105 -0
  28. data/lib/virgil/sdk/client/requests/revoke_card_request.rb +85 -0
  29. data/lib/virgil/sdk/client/requests/signable_request.rb +142 -0
  30. data/lib/virgil/sdk/client/requests/verify_identity_request.rb +60 -0
  31. data/lib/virgil/sdk/client/search_criteria.rb +79 -0
  32. data/lib/virgil/sdk/client/signatures_base64.rb +25 -0
  33. data/lib/virgil/sdk/client/virgil_client.rb +425 -0
  34. data/lib/virgil/sdk/cryptography.rb +42 -0
  35. data/lib/virgil/sdk/cryptography/hashes.rb +44 -0
  36. data/lib/virgil/sdk/cryptography/hashes/fingerprint.rb +79 -0
  37. data/lib/virgil/sdk/cryptography/hashes/hash_algorithm.rb +91 -0
  38. data/lib/virgil/sdk/cryptography/keys.rb +48 -0
  39. data/lib/virgil/sdk/cryptography/keys/key_pair.rb +46 -0
  40. data/lib/virgil/sdk/cryptography/keys/key_pair_type.rb +108 -0
  41. data/lib/virgil/sdk/cryptography/keys/key_storage.rb +177 -0
  42. data/lib/virgil/sdk/cryptography/keys/private_key.rb +44 -0
  43. data/lib/virgil/sdk/cryptography/keys/public_key.rb +44 -0
  44. data/lib/virgil/sdk/cryptography/keys/storage_item.rb +63 -0
  45. data/lib/virgil/sdk/cryptography/virgil_crypto.rb +411 -0
  46. data/lib/virgil/sdk/high_level.rb +21 -0
  47. data/lib/virgil/sdk/high_level/virgil_api.rb +71 -0
  48. data/lib/virgil/sdk/high_level/virgil_app_credentials.rb +54 -0
  49. data/lib/virgil/sdk/high_level/virgil_buffer.rb +161 -0
  50. data/lib/virgil/sdk/high_level/virgil_card.rb +204 -0
  51. data/lib/virgil/sdk/high_level/virgil_card_manager.rb +294 -0
  52. data/lib/virgil/sdk/high_level/virgil_card_verifier_info.rb +49 -0
  53. data/lib/virgil/sdk/high_level/virgil_context.rb +69 -0
  54. data/lib/virgil/sdk/high_level/virgil_identity.rb +17 -0
  55. data/lib/virgil/sdk/high_level/virgil_identity/email_confirmation.rb +60 -0
  56. data/lib/virgil/sdk/high_level/virgil_identity/validation_token.rb +49 -0
  57. data/lib/virgil/sdk/high_level/virgil_identity/verification_attempt.rb +69 -0
  58. data/lib/virgil/sdk/high_level/virgil_identity/verification_options.rb +56 -0
  59. data/lib/virgil/sdk/high_level/virgil_key.rb +168 -0
  60. data/lib/virgil/sdk/high_level/virgil_key_manager.rb +97 -0
  61. data/lib/virgil/sdk/version.rb +5 -0
  62. data/virgil-sdk.gemspec +31 -0
  63. metadata +203 -0
@@ -0,0 +1,49 @@
1
+ # Copyright (C) 2016 Virgil Security Inc.
2
+ #
3
+ # Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
4
+ #
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions are
9
+ # met:
10
+ #
11
+ # (1) Redistributions of source code must retain the above copyright
12
+ # notice, this list of conditions and the following disclaimer.
13
+ #
14
+ # (2) Redistributions in binary form must reproduce the above copyright
15
+ # notice, this list of conditions and the following disclaimer in
16
+ # the documentation and/or other materials provided with the
17
+ # distribution.
18
+ #
19
+ # (3) Neither the name of the copyright holder nor the names of its
20
+ # contributors may be used to endorse or promote products derived from
21
+ # this software without specific prior written permission.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
24
+ # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
+ # POSSIBILITY OF SUCH DAMAGE.
34
+ module Virgil
35
+ module SDK
36
+ module HighLevel
37
+ module VirgilIdentity
38
+ class ValidationToken
39
+ attr_reader :value
40
+
41
+ def initialize(value)
42
+ @value = value
43
+ end
44
+
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,69 @@
1
+ # Copyright (C) 2016 Virgil Security Inc.
2
+ #
3
+ # Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
4
+ #
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions are
9
+ # met:
10
+ #
11
+ # (1) Redistributions of source code must retain the above copyright
12
+ # notice, this list of conditions and the following disclaimer.
13
+ #
14
+ # (2) Redistributions in binary form must reproduce the above copyright
15
+ # notice, this list of conditions and the following disclaimer in
16
+ # the documentation and/or other materials provided with the
17
+ # distribution.
18
+ #
19
+ # (3) Neither the name of the copyright holder nor the names of its
20
+ # contributors may be used to endorse or promote products derived from
21
+ # this software without specific prior written permission.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
24
+ # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
+ # POSSIBILITY OF SUCH DAMAGE.
34
+ module Virgil
35
+ module SDK
36
+ module HighLevel
37
+ module VirgilIdentity
38
+ class VerificationAttempt
39
+ attr_reader :action_id, :context, :additional_options, :identity, :identity_type
40
+
41
+ def initialize(context:, action_id:, identity:, identity_type:, additional_options: nil)
42
+ @context = context
43
+ @action_id = action_id
44
+ @identity = identity
45
+ @identity_type = identity_type
46
+ @additional_options = additional_options || VerificationOptions.new
47
+ end
48
+
49
+
50
+ def confirm(confirmation)
51
+ raise ConfirmationIsNotValid unless confirmation
52
+ token = confirmation.confirm_and_grab_validation_token(self, self.context.client)
53
+ ValidationToken.new(token)
54
+
55
+ end
56
+ end
57
+
58
+
59
+ class ConfirmationIsNotValid < StandardError
60
+ def to_s
61
+ "Confirmation is not valid"
62
+ end
63
+ end
64
+
65
+ end
66
+
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,56 @@
1
+ # Copyright (C) 2016 Virgil Security Inc.
2
+ #
3
+ # Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
4
+ #
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions are
9
+ # met:
10
+ #
11
+ # (1) Redistributions of source code must retain the above copyright
12
+ # notice, this list of conditions and the following disclaimer.
13
+ #
14
+ # (2) Redistributions in binary form must reproduce the above copyright
15
+ # notice, this list of conditions and the following disclaimer in
16
+ # the documentation and/or other materials provided with the
17
+ # distribution.
18
+ #
19
+ # (3) Neither the name of the copyright holder nor the names of its
20
+ # contributors may be used to endorse or promote products derived from
21
+ # this software without specific prior written permission.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
24
+ # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
+ # POSSIBILITY OF SUCH DAMAGE.
34
+ module Virgil
35
+ module SDK
36
+ module HighLevel
37
+ module VirgilIdentity
38
+ class VerificationOptions
39
+
40
+ # time_to_live is used to limit the lifetime of the token in
41
+ # seconds (maximum value is 60 * 60 * 24 * 365 = 1 year). Default value is 3600.
42
+ #
43
+ # count_to_live parameter is used to restrict the number of validation token
44
+ # usages (maximum value is 100).
45
+ attr_reader :time_to_live, :count_to_live
46
+
47
+ def initialize(options = {})
48
+ @time_to_live = options[:time_to_live] || 3600
49
+ @count_to_live = options[:count_to_live] || 12
50
+ end
51
+
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,168 @@
1
+ # Copyright (C) 2016 Virgil Security Inc.
2
+ #
3
+ # Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
4
+ #
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions are
9
+ # met:
10
+ #
11
+ # (1) Redistributions of source code must retain the above copyright
12
+ # notice, this list of conditions and the following disclaimer.
13
+ #
14
+ # (2) Redistributions in binary form must reproduce the above copyright
15
+ # notice, this list of conditions and the following disclaimer in
16
+ # the documentation and/or other materials provided with the
17
+ # distribution.
18
+ #
19
+ # (3) Neither the name of the copyright holder nor the names of its
20
+ # contributors may be used to endorse or promote products derived from
21
+ # this software without specific prior written permission.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
24
+ # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
+ # POSSIBILITY OF SUCH DAMAGE.
34
+ module Virgil
35
+ module SDK
36
+ module HighLevel
37
+ # This class represents a user's high-level Private key which provides
38
+ # a list of methods that allows to store the key and perform cryptographic operations like
39
+ # Decrypt, Sign etc.
40
+ class VirgilKey
41
+ attr_reader :context, :private_key
42
+
43
+ def initialize(context, private_key)
44
+ @context = context
45
+ @private_key = private_key
46
+ end
47
+
48
+
49
+ # Decrypts the specified cipher data using Virgil key.
50
+ #
51
+ # Args:
52
+ # cipher_buffer: The encrypted data wrapped by VirgilBuffer.
53
+ #
54
+ # Returns:
55
+ # A byte array containing the result from performing the operation wrapped by VirgilBuffer.
56
+ #
57
+ # Raises:
58
+ # ArgumentError: buffer is not valid if buffer doesn't have type VirgilBuffer or String
59
+ # Recipient with given identifier is not found if user tries to decrypt cipher data by private key,
60
+ # though its public key was not used for encryption
61
+ def decrypt(cipher_buffer)
62
+ VirgilBuffer.validate_buffer_param(cipher_buffer, "cipher buffer")
63
+ bytes = context.crypto.decrypt(cipher_buffer.bytes, private_key)
64
+ VirgilBuffer.new(bytes)
65
+ end
66
+
67
+
68
+ # Generates a digital signature for specified data using current Virgil key.
69
+ #
70
+ # Args:
71
+ # buffer: The data wrapped by VirgilBuffer for which the digital signature will be generated.
72
+ #
73
+ # Returns:
74
+ # A new buffer that containing the result from performing the operation.
75
+ #
76
+ # Raises:
77
+ # ArgumentError: buffer is not valid if buffer doesn't have type VirgilBuffer or String
78
+ def sign(buffer)
79
+ VirgilBuffer.validate_buffer_param(buffer)
80
+ bytes = context.crypto.sign(buffer.bytes, private_key)
81
+ VirgilBuffer.new(bytes)
82
+ end
83
+
84
+
85
+ # Encrypts and signs the data.
86
+ #
87
+ # Args:
88
+ # buffer: The data wrapped by VirgilBuffer to be encrypted and signed
89
+ # recipients: The list of VirgilCard recipients.
90
+ #
91
+ # Returns:
92
+ # A new buffer that containing the encrypted and signed data
93
+ #
94
+
95
+ # Raises:
96
+ # ArgumentError: buffer is not valid if buffer doesn't have type VirgilBuffer or String
97
+ # ArgumentError: recipients is not valid if recipients doesn't have type Array or empty
98
+ def sign_then_encrypt(buffer, recipients)
99
+
100
+ VirgilBuffer.validate_buffer_param(buffer)
101
+ raise ArgumentError.new("recipients is not valid") if (!recipients.is_a?(Array) || recipients.empty?)
102
+ public_keys = recipients.map(&:public_key)
103
+ bytes = context.crypto.sign_then_encrypt(buffer.bytes, private_key, *public_keys)
104
+ VirgilBuffer.new(bytes)
105
+
106
+ end
107
+
108
+
109
+ # Decrypts and verifies the data.
110
+ #
111
+ # Args:
112
+ # cipher_buffer: The data to be decrypted and verified
113
+ # card: The signer's VirgilCard
114
+ #
115
+ # Returns:
116
+ # The decrypted data, which is the original plain text before encryption The decrypted data, wrapped by VirgilBuffer
117
+ #
118
+ # Raises:
119
+ # ArgumentError: buffer is not valid if buffer doesn't have type VirgilBuffer or String
120
+ # ArgumentError: recipients is not valid if recipients doesn't have type Array or empty
121
+ def decrypt_then_verify(cipher_buffer, card)
122
+
123
+ VirgilBuffer.validate_buffer_param(cipher_buffer, "cipher buffer")
124
+ raise ArgumentError.new("card is not valid") unless card.is_a?(VirgilCard)
125
+
126
+ bytes = context.crypto.decrypt_then_verify(cipher_buffer.bytes, private_key, card.public_key)
127
+ VirgilBuffer.new(bytes)
128
+ end
129
+
130
+
131
+ # Saves a current VirgilKey in secure storage.
132
+ #
133
+ # Args:
134
+ # key_name: The name of the key.
135
+ # key_password: The key password.
136
+ #
137
+ # Returns:
138
+ # An instance of VirgilKey class
139
+ #
140
+ # Raises:
141
+ # KeyEntryAlreadyExistsException: if key storage already has item with such name
142
+ # ArgumentError: key_name is not valid if key_name is nil
143
+ # KeyStorageException: Destination folder doesn't exist or you don't have permission to write there
144
+ def save(key_name, key_password=nil)
145
+
146
+ raise ArgumentError.new("key_name is not valid") if key_name.nil?
147
+
148
+ exported_private_key = context.crypto.export_private_key(private_key, key_password)
149
+ storage_item = Cryptography::Keys::StorageItem.new(key_name, exported_private_key)
150
+ context.key_storage.store(storage_item)
151
+ self
152
+
153
+ end
154
+
155
+
156
+ # Exports the Public key value from current VirgilKey.
157
+ #
158
+ # Returns:
159
+ # A new VirgilBuffer that contains Public Key value.
160
+ def export_public_key
161
+ public_key = context.crypto.extract_public_key(private_key)
162
+ VirgilBuffer.from_bytes(context.crypto.export_public_key(public_key))
163
+ end
164
+
165
+ end
166
+ end
167
+ end
168
+ end
@@ -0,0 +1,97 @@
1
+ # Copyright (C) 2016 Virgil Security Inc.
2
+ #
3
+ # Lead Maintainer: Virgil Security Inc. <support@virgilsecurity.com>
4
+ #
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions are
9
+ # met:
10
+ #
11
+ # (1) Redistributions of source code must retain the above copyright
12
+ # notice, this list of conditions and the following disclaimer.
13
+ #
14
+ # (2) Redistributions in binary form must reproduce the above copyright
15
+ # notice, this list of conditions and the following disclaimer in
16
+ # the documentation and/or other materials provided with the
17
+ # distribution.
18
+ #
19
+ # (3) Neither the name of the copyright holder nor the names of its
20
+ # contributors may be used to endorse or promote products derived from
21
+ # this software without specific prior written permission.
22
+ #
23
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR
24
+ # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+ # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27
+ # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30
+ # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31
+ # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32
+ # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33
+ # POSSIBILITY OF SUCH DAMAGE.
34
+ module Virgil
35
+ module SDK
36
+ module HighLevel
37
+ # this class provides a list of methods to generate the VirgilKey
38
+ # and further them storage in secure place.
39
+ class VirgilKeyManager
40
+ attr_reader :context
41
+
42
+ def initialize(context)
43
+ @context = context
44
+ end
45
+
46
+
47
+ # Generates a new VirgilKey with default parameters.
48
+ def generate
49
+ key_pair = context.crypto.generate_keys()
50
+ VirgilKey.new(context, key_pair.private_key)
51
+ end
52
+
53
+
54
+ # Loads the VirgilKey from current storage by specified key name.
55
+ #
56
+ # Args:
57
+ # key_name: The name of the key.
58
+ # key_password: The key password.
59
+ #
60
+ # Returns:
61
+ # An instance of VirgilKey class
62
+ #
63
+ # Raises:
64
+ # KeyEntryNotFoundException: if key storage doesn't have item with such name
65
+ # ArgumentError: key_name is not valid if key_name is nil
66
+ # KeyStorageException: Destination folder doesn't exist or you don't have permission to write there
67
+ def load(key_name, key_password=nil)
68
+
69
+ raise ArgumentError.new("key_name is not valid") if key_name.nil?
70
+
71
+ storage_item = context.key_storage.load(key_name)
72
+ private_key = context.crypto.import_private_key(storage_item.data, key_password)
73
+ VirgilKey.new(context, private_key)
74
+
75
+ end
76
+
77
+
78
+ # Remove the VirgilKey from current storage by specified key name.
79
+ #
80
+ # Args:
81
+ # key_name: The name of the key.
82
+ #
83
+ # Raises:
84
+ # KeyEntryNotFoundException: if key storage doesn't have item with such name
85
+ # ArgumentError: key_name is not valid if key_name is nil
86
+ # KeyStorageException: Destination folder doesn't exist or you don't have permission to write there
87
+ def delete(key_name)
88
+
89
+ raise ArgumentError.new("key_name is not valid") if key_name.nil?
90
+
91
+ context.key_storage.delete(key_name)
92
+ end
93
+
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,5 @@
1
+ module Virgil
2
+ module SDK
3
+ VERSION = "4.2.3"
4
+ end
5
+ end