licensing 0.41__tar.gz → 0.42__tar.gz
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.
- {licensing-0.41 → licensing-0.42}/PKG-INFO +2 -2
- {licensing-0.41 → licensing-0.42}/licensing/internal.py +26 -4
- {licensing-0.41 → licensing-0.42}/licensing/methods.py +15 -1
- {licensing-0.41 → licensing-0.42}/licensing/models.py +9 -2
- {licensing-0.41 → licensing-0.42}/setup.py +2 -2
- {licensing-0.41 → licensing-0.42}/licensing/__init__.py +0 -0
- {licensing-0.41 → licensing-0.42}/setup.cfg +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 1.1
|
|
2
2
|
Name: licensing
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.42
|
|
4
4
|
Summary: Client library for Cryptolens licensing Web API.
|
|
5
5
|
Home-page: https://cryptolens.io
|
|
6
6
|
Author: Cryptolens AB
|
|
7
7
|
Author-email: support@cryptolens.io
|
|
8
8
|
License: MIT
|
|
9
|
-
Download-URL: https://github.com/Cryptolens/cryptolens-python/archive/
|
|
9
|
+
Download-URL: https://github.com/Cryptolens/cryptolens-python/archive/v_42.tar.gz
|
|
10
10
|
Description: UNKNOWN
|
|
11
11
|
Keywords: software licensing,licensing library,cryptolens
|
|
12
12
|
Platform: UNKNOWN
|
|
@@ -70,28 +70,33 @@ class HelperMethods:
|
|
|
70
70
|
return pow(s, e, n)
|
|
71
71
|
|
|
72
72
|
@staticmethod
|
|
73
|
-
def EMSA_PKCS1_V15_ENCODE(M, emLen):
|
|
73
|
+
def EMSA_PKCS1_V15_ENCODE(M, emLen, hlen = 256):
|
|
74
74
|
import hashlib
|
|
75
75
|
h = hashlib.sha256()
|
|
76
|
+
if hlen == 512:
|
|
77
|
+
h = hashlib.sha512()
|
|
76
78
|
h.update(M)
|
|
77
79
|
H = h.digest()
|
|
78
80
|
|
|
79
81
|
T = bytes([0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20]) + H
|
|
82
|
+
if hlen == 512:
|
|
83
|
+
T = bytes([0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40]) + H
|
|
84
|
+
|
|
80
85
|
tLen = len(T)
|
|
81
86
|
if emLen < tLen + 11:
|
|
82
87
|
return None
|
|
83
88
|
PS = bytes([0xff for _ in range(emLen - tLen - 3)])
|
|
84
89
|
return b"".join([b"\x00\x01", PS, b"\x00", T])
|
|
85
|
-
|
|
90
|
+
|
|
86
91
|
@staticmethod
|
|
87
|
-
def RSAASSA_PKCS1_V15_VERIFY(pair, M, S):
|
|
92
|
+
def RSAASSA_PKCS1_V15_VERIFY(pair, M, S, l=256):
|
|
88
93
|
n, e = pair
|
|
89
94
|
s = HelperMethods.OS2IP(S)
|
|
90
95
|
m = HelperMethods.RSAVP1((n,e), s)
|
|
91
96
|
if m is None: return False
|
|
92
97
|
EM = HelperMethods.I2OSP(m, 256)
|
|
93
98
|
if EM is None: return False
|
|
94
|
-
EM2 = HelperMethods.EMSA_PKCS1_V15_ENCODE(M, 256)
|
|
99
|
+
EM2 = HelperMethods.EMSA_PKCS1_V15_ENCODE(M, 256, l)
|
|
95
100
|
if EM2 is None: return False
|
|
96
101
|
|
|
97
102
|
try:
|
|
@@ -114,6 +119,23 @@ class HelperMethods:
|
|
|
114
119
|
|
|
115
120
|
return HelperMethods.RSAASSA_PKCS1_V15_VERIFY((n,e), m, r)
|
|
116
121
|
|
|
122
|
+
@staticmethod
|
|
123
|
+
def verify_signature_metadata(signature, rsaPublicKey):
|
|
124
|
+
|
|
125
|
+
import base64
|
|
126
|
+
import json
|
|
127
|
+
|
|
128
|
+
n = HelperMethods.OS2IP(base64.b64decode(rsaPublicKey.modulus))
|
|
129
|
+
e = HelperMethods.OS2IP(base64.b64decode(rsaPublicKey.exponent))
|
|
130
|
+
|
|
131
|
+
data = json.loads(base64.b64decode(signature))
|
|
132
|
+
|
|
133
|
+
d = base64.b64decode(data["Data"])
|
|
134
|
+
s = base64.b64decode(data["Signature"])
|
|
135
|
+
|
|
136
|
+
return [HelperMethods.RSAASSA_PKCS1_V15_VERIFY((n,e), d,s, l=512), d]
|
|
137
|
+
|
|
138
|
+
|
|
117
139
|
@staticmethod
|
|
118
140
|
def int2base64(num):
|
|
119
141
|
return base64.b64encode(int.to_bytes(num), byteorder='big')
|
|
@@ -61,7 +61,21 @@ class Key:
|
|
|
61
61
|
else:
|
|
62
62
|
try:
|
|
63
63
|
if HelperMethods.verify_signature(response, pubkey):
|
|
64
|
-
|
|
64
|
+
if metadata:
|
|
65
|
+
|
|
66
|
+
try:
|
|
67
|
+
metadata_s = HelperMethods.verify_signature_metadata(response.metadata["signature"], pubkey)
|
|
68
|
+
|
|
69
|
+
if metadata_s[0]:
|
|
70
|
+
return (LicenseKey.from_response(response), response.message, json.loads(metadata_s[1]))
|
|
71
|
+
else:
|
|
72
|
+
return (LicenseKey.from_response(response), response.message, "Signature check for metadata object failed.")
|
|
73
|
+
except:
|
|
74
|
+
return (LicenseKey.from_response(response), response.message, "Signature check for metadata object failed.")
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
else:
|
|
78
|
+
return (LicenseKey.from_response(response), response.message)
|
|
65
79
|
else:
|
|
66
80
|
return (None, "The signature check failed.")
|
|
67
81
|
except Exception as ex:
|
|
@@ -164,11 +164,12 @@ class LicenseKey:
|
|
|
164
164
|
|
|
165
165
|
class Response:
|
|
166
166
|
|
|
167
|
-
def __init__(self, license_key, signature, result, message):
|
|
167
|
+
def __init__(self, license_key, signature, result, message, metadata=None):
|
|
168
168
|
self.license_key = license_key
|
|
169
169
|
self.signature = signature
|
|
170
170
|
self.result = result
|
|
171
171
|
self.message = message
|
|
172
|
+
self.metadata = metadata
|
|
172
173
|
|
|
173
174
|
@staticmethod
|
|
174
175
|
def from_string(responseString):
|
|
@@ -178,6 +179,7 @@ class Response:
|
|
|
178
179
|
signature = ""
|
|
179
180
|
result = 0
|
|
180
181
|
message = ""
|
|
182
|
+
metadata = None
|
|
181
183
|
|
|
182
184
|
if "licensekey" in obj:
|
|
183
185
|
licenseKey = obj["licensekey"]
|
|
@@ -192,8 +194,13 @@ class Response:
|
|
|
192
194
|
result = obj["result"]
|
|
193
195
|
else:
|
|
194
196
|
result = 1
|
|
197
|
+
|
|
198
|
+
if "metadata" in obj:
|
|
199
|
+
metadata = obj["metadata"]
|
|
200
|
+
|
|
201
|
+
|
|
195
202
|
|
|
196
|
-
return Response(licenseKey, signature, result, message)
|
|
203
|
+
return Response(licenseKey, signature, result, message, metadata)
|
|
197
204
|
|
|
198
205
|
class RSAPublicKey:
|
|
199
206
|
|
|
@@ -2,13 +2,13 @@ from distutils.core import setup
|
|
|
2
2
|
setup(
|
|
3
3
|
name = 'licensing', # How you named your package folder (MyLib)
|
|
4
4
|
packages = ['licensing'], # Chose the same as "name"
|
|
5
|
-
version = '0.
|
|
5
|
+
version = '0.42', # Start with a small number and increase it with every change you make
|
|
6
6
|
license='MIT', # Chose a license from here: https://help.github.com/articles/licensing-a-repository
|
|
7
7
|
description = 'Client library for Cryptolens licensing Web API.', # Give a short description about your library
|
|
8
8
|
author = 'Cryptolens AB', # Type in your name
|
|
9
9
|
author_email = 'support@cryptolens.io', # Type in your E-Mail
|
|
10
10
|
url = 'https://cryptolens.io', # Provide either the link to your github or to your website
|
|
11
|
-
download_url = 'https://github.com/Cryptolens/cryptolens-python/archive/
|
|
11
|
+
download_url = 'https://github.com/Cryptolens/cryptolens-python/archive/v_42.tar.gz', # I explain this later on
|
|
12
12
|
keywords = ['software licensing', 'licensing library', 'cryptolens'], # Keywords that define your package best
|
|
13
13
|
classifiers=[
|
|
14
14
|
#'Development Status :: 5 - Stable', # Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable" as the current state of your package
|
|
File without changes
|
|
File without changes
|