DLMS-SPODES-client 0.19.35__py3-none-any.whl → 0.19.37__py3-none-any.whl

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.
Files changed (60) hide show
  1. DLMS_SPODES_client/FCS16.py +39 -39
  2. DLMS_SPODES_client/__init__.py +12 -12
  3. DLMS_SPODES_client/client.py +2093 -2093
  4. DLMS_SPODES_client/gurux_common/enums/TraceLevel.py +21 -21
  5. DLMS_SPODES_client/gurux_dlms/AesGcmParameter.py +37 -37
  6. DLMS_SPODES_client/gurux_dlms/CountType.py +16 -16
  7. DLMS_SPODES_client/gurux_dlms/GXByteBuffer.py +545 -545
  8. DLMS_SPODES_client/gurux_dlms/GXCiphering.py +196 -196
  9. DLMS_SPODES_client/gurux_dlms/GXDLMS.py +426 -426
  10. DLMS_SPODES_client/gurux_dlms/GXDLMSChippering.py +237 -237
  11. DLMS_SPODES_client/gurux_dlms/GXDLMSChipperingStream.py +977 -977
  12. DLMS_SPODES_client/gurux_dlms/GXDLMSConfirmedServiceError.py +90 -90
  13. DLMS_SPODES_client/gurux_dlms/GXDLMSException.py +139 -139
  14. DLMS_SPODES_client/gurux_dlms/GXDLMSLNParameters.py +33 -33
  15. DLMS_SPODES_client/gurux_dlms/GXDLMSSNParameters.py +21 -21
  16. DLMS_SPODES_client/gurux_dlms/GXDLMSSettings.py +254 -254
  17. DLMS_SPODES_client/gurux_dlms/GXReplyData.py +87 -87
  18. DLMS_SPODES_client/gurux_dlms/HdlcControlFrame.py +9 -9
  19. DLMS_SPODES_client/gurux_dlms/MBusCommand.py +8 -8
  20. DLMS_SPODES_client/gurux_dlms/MBusEncryptionMode.py +27 -27
  21. DLMS_SPODES_client/gurux_dlms/ResponseType.py +8 -8
  22. DLMS_SPODES_client/gurux_dlms/SetResponseType.py +29 -29
  23. DLMS_SPODES_client/gurux_dlms/_HDLCInfo.py +9 -9
  24. DLMS_SPODES_client/gurux_dlms/__init__.py +75 -75
  25. DLMS_SPODES_client/gurux_dlms/enums/Access.py +12 -12
  26. DLMS_SPODES_client/gurux_dlms/enums/ApplicationReference.py +14 -14
  27. DLMS_SPODES_client/gurux_dlms/enums/Authentication.py +41 -41
  28. DLMS_SPODES_client/gurux_dlms/enums/BerType.py +35 -35
  29. DLMS_SPODES_client/gurux_dlms/enums/Command.py +285 -285
  30. DLMS_SPODES_client/gurux_dlms/enums/Definition.py +9 -9
  31. DLMS_SPODES_client/gurux_dlms/enums/ErrorCode.py +46 -46
  32. DLMS_SPODES_client/gurux_dlms/enums/ExceptionServiceError.py +12 -12
  33. DLMS_SPODES_client/gurux_dlms/enums/HardwareResource.py +10 -10
  34. DLMS_SPODES_client/gurux_dlms/enums/HdlcFrameType.py +9 -9
  35. DLMS_SPODES_client/gurux_dlms/enums/Initiate.py +10 -10
  36. DLMS_SPODES_client/gurux_dlms/enums/LoadDataSet.py +13 -13
  37. DLMS_SPODES_client/gurux_dlms/enums/ObjectType.py +306 -306
  38. DLMS_SPODES_client/gurux_dlms/enums/Priority.py +7 -7
  39. DLMS_SPODES_client/gurux_dlms/enums/RequestTypes.py +9 -9
  40. DLMS_SPODES_client/gurux_dlms/enums/Security.py +14 -14
  41. DLMS_SPODES_client/gurux_dlms/enums/Service.py +16 -16
  42. DLMS_SPODES_client/gurux_dlms/enums/ServiceClass.py +9 -9
  43. DLMS_SPODES_client/gurux_dlms/enums/ServiceError.py +8 -8
  44. DLMS_SPODES_client/gurux_dlms/enums/Standard.py +18 -18
  45. DLMS_SPODES_client/gurux_dlms/enums/StateError.py +7 -7
  46. DLMS_SPODES_client/gurux_dlms/enums/Task.py +10 -10
  47. DLMS_SPODES_client/gurux_dlms/enums/VdeStateError.py +10 -10
  48. DLMS_SPODES_client/gurux_dlms/enums/__init__.py +33 -33
  49. DLMS_SPODES_client/gurux_dlms/internal/_GXCommon.py +1673 -1673
  50. DLMS_SPODES_client/logger.py +56 -56
  51. DLMS_SPODES_client/services.py +90 -90
  52. DLMS_SPODES_client/session.py +363 -363
  53. DLMS_SPODES_client/settings.py +48 -48
  54. DLMS_SPODES_client/task.py +1884 -1884
  55. {dlms_spodes_client-0.19.35.dist-info → dlms_spodes_client-0.19.37.dist-info}/METADATA +29 -29
  56. dlms_spodes_client-0.19.37.dist-info/RECORD +61 -0
  57. {dlms_spodes_client-0.19.35.dist-info → dlms_spodes_client-0.19.37.dist-info}/WHEEL +1 -1
  58. dlms_spodes_client-0.19.35.dist-info/RECORD +0 -61
  59. {dlms_spodes_client-0.19.35.dist-info → dlms_spodes_client-0.19.37.dist-info}/entry_points.txt +0 -0
  60. {dlms_spodes_client-0.19.35.dist-info → dlms_spodes_client-0.19.37.dist-info}/top_level.txt +0 -0
@@ -1,196 +1,196 @@
1
- from .enums import Security
2
- from DLMS_SPODES.cosem_interface_classes.security_setup.ver1 import SecuritySuite
3
- from .GXDLMSChippering import GXDLMSChippering
4
- from . import AesGcmParameter
5
- from .GXByteBuffer import GXByteBuffer
6
-
7
-
8
- # pylint: disable=too-many-instance-attributes, too-many-function-args, too-many-public-methods
9
- class GXCiphering:
10
- """
11
- Gurux DLMS/COSEM Transport security (Ciphering) settings.
12
- """
13
- def __init__(self, title):
14
- """
15
- # Constructor. Default values are from the Green Book.
16
- title: Used system title.
17
- """
18
- self.publicKeys = list()
19
- self.certificates = list()
20
- self.security = Security.NONE
21
- # System title.
22
- self.systemTitle = title
23
- # Block cipher key.
24
- self.blockCipherKey = bytearray((0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F))
25
- self.authenticationKey = bytearray((0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF))
26
- # Dedicated key.
27
- self.dedicatedKey = None
28
- # Certificates.
29
- self.certificates = None
30
- # Ephemeral key pair.
31
- self.ephemeralKeyPair = None
32
- # recipient system title.
33
- self.recipientSystemTitle = None
34
- # Invocation Counter.
35
- self.invocationCounter = 0
36
- # Used security suite.
37
- self.securitySuite = SecuritySuite.AES_GCM_128_AUT_ENCR_AND_AES_128_KEY_WRAP
38
- # Signing key pair.
39
- self.signingKeyPair = None
40
- # Client key agreement key pair.
41
- self.keyAgreementKeyPair = None
42
- # Target (Server or client) Public key.
43
- self.publicKeys = None
44
- # Shared secret is generated when connection is made.
45
- self.sharedSecret = None
46
-
47
- @classmethod
48
- def decrypt(cls, c, p, data):
49
- tmp = []
50
- p.sharedSecret = c.sharedSecret
51
- tmp = GXDLMSChippering.decryptAesGcm(p, data)
52
- c.sharedSecret = p.sharedSecret
53
- return tmp
54
-
55
- #
56
- # Cipher PDU.
57
- # *
58
- # @param p
59
- # Aes GCM Parameter.
60
- # @param data
61
- # Plain text.
62
- # @return Secured data.
63
- #
64
- @classmethod
65
- def encrypt(cls, p, data) -> bytearray:
66
- if p.security != Security.NONE:
67
- tmp = GXDLMSChippering.encryptAesGcm(p, data)
68
- p.invocationCounter = p.invocationCounter + 1
69
- return tmp
70
- return data
71
-
72
- def reset(self):
73
- """
74
- Reset encrypt settings.
75
- """
76
- self.security = Security.NONE
77
- self.invocationCounter = 0
78
-
79
- def isCiphered(self):
80
- """
81
- Is ciphering used.
82
- """
83
- return self.security != Security.NONE
84
-
85
- #
86
- # Generate GMAC password from given challenge.
87
- # *
88
- # @param challenge
89
- # Client to Server or Server to Client challenge.
90
- # @return Generated challenge.
91
- #
92
- def generateGmacPassword(self, challenge):
93
- p = AesGcmParameter(0x10, self.systemTitle, self.blockCipherKey, self.authenticationKey)
94
- p.security = Security.AUTHENTICATION
95
- p.invocationCounter = self.invocationCounter
96
- bb = GXByteBuffer()
97
- GXDLMSChippering.encryptAesGcm(p, challenge)
98
- bb.setUInt8(0x10)
99
- bb.setUInt32(self.invocationCounter)
100
- bb.set(p.countTag)
101
- return bb.array()
102
-
103
- def getSecurity(self):
104
- """
105
- Used security.
106
- """
107
- return self.security
108
-
109
- def setSecurity(self, value):
110
- """
111
- Used security.
112
- """
113
- self.security = value
114
-
115
- def getSystemTitle(self):
116
- """
117
- System title.
118
- """
119
- return self.systemTitle
120
-
121
- #
122
- # Recipient system Title.
123
- #
124
- def getRecipientSystemTitle(self):
125
- """
126
- Recipient system Title.
127
- """
128
- return self.recipientSystemTitle
129
-
130
- def getBlockCipherKey(self):
131
- # Block cipher key.
132
- return self.blockCipherKey
133
-
134
- def getAuthenticationKey(self):
135
- # Authentication key.
136
- return self.authenticationKey
137
-
138
- def setAuthenticationKey(self, value):
139
- # Authentication key.
140
- self.authenticationKey = value
141
-
142
- def getInvocationCounter(self):
143
- # Invocation counter.
144
- return self.invocationCounter
145
-
146
- def getSecuritySuite(self):
147
- # Used security suite.
148
- return self.securitySuite
149
-
150
- def getEphemeralKeyPair(self):
151
- # Ephemeral key pair.
152
- return self.ephemeralKeyPair
153
-
154
- def setEphemeralKeyPair(self, value):
155
- # Ephemeral key pair.
156
- self.ephemeralKeyPair = value
157
-
158
- def getKeyAgreementKeyPair(self):
159
- # Client's key agreement key pair.
160
- return self.keyAgreementKeyPair
161
-
162
- def setKeyAgreementKeyPair(self, value):
163
- # Client's key agreement key pair.
164
- self.keyAgreementKeyPair = value
165
-
166
- def getPublicKeys(self):
167
- # Target (Server or client) Public key.
168
- return self.publicKeys
169
-
170
- def getCertificates(self):
171
- # Available certificates.
172
- return self.certificates
173
-
174
- def getSigningKeyPair(self):
175
- # Signing key pair.
176
- return self.signingKeyPair
177
-
178
- def setSigningKeyPair(self, value):
179
- # Signing key pair.
180
- self.signingKeyPair = value
181
-
182
- def getSharedSecret(self):
183
- # Shared secret is generated when connection is made.
184
- return self.sharedSecret
185
-
186
- def setSharedSecret(self, value):
187
- # Shared secret is generated when connection is made.
188
- self.sharedSecret = value
189
-
190
- def getDedicatedKey(self):
191
- # Dedicated key.
192
- return self.dedicatedKey
193
-
194
- def setDedicatedKey(self, value):
195
- # Dedicated key.
196
- self.dedicatedKey = value
1
+ from .enums import Security
2
+ from DLMS_SPODES.cosem_interface_classes.security_setup.ver1 import SecuritySuite
3
+ from .GXDLMSChippering import GXDLMSChippering
4
+ from . import AesGcmParameter
5
+ from .GXByteBuffer import GXByteBuffer
6
+
7
+
8
+ # pylint: disable=too-many-instance-attributes, too-many-function-args, too-many-public-methods
9
+ class GXCiphering:
10
+ """
11
+ Gurux DLMS/COSEM Transport security (Ciphering) settings.
12
+ """
13
+ def __init__(self, title):
14
+ """
15
+ # Constructor. Default values are from the Green Book.
16
+ title: Used system title.
17
+ """
18
+ self.publicKeys = list()
19
+ self.certificates = list()
20
+ self.security = Security.NONE
21
+ # System title.
22
+ self.systemTitle = title
23
+ # Block cipher key.
24
+ self.blockCipherKey = bytearray((0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F))
25
+ self.authenticationKey = bytearray((0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF))
26
+ # Dedicated key.
27
+ self.dedicatedKey = None
28
+ # Certificates.
29
+ self.certificates = None
30
+ # Ephemeral key pair.
31
+ self.ephemeralKeyPair = None
32
+ # recipient system title.
33
+ self.recipientSystemTitle = None
34
+ # Invocation Counter.
35
+ self.invocationCounter = 0
36
+ # Used security suite.
37
+ self.securitySuite = SecuritySuite.AES_GCM_128_AUT_ENCR_AND_AES_128_KEY_WRAP
38
+ # Signing key pair.
39
+ self.signingKeyPair = None
40
+ # Client key agreement key pair.
41
+ self.keyAgreementKeyPair = None
42
+ # Target (Server or client) Public key.
43
+ self.publicKeys = None
44
+ # Shared secret is generated when connection is made.
45
+ self.sharedSecret = None
46
+
47
+ @classmethod
48
+ def decrypt(cls, c, p, data):
49
+ tmp = []
50
+ p.sharedSecret = c.sharedSecret
51
+ tmp = GXDLMSChippering.decryptAesGcm(p, data)
52
+ c.sharedSecret = p.sharedSecret
53
+ return tmp
54
+
55
+ #
56
+ # Cipher PDU.
57
+ # *
58
+ # @param p
59
+ # Aes GCM Parameter.
60
+ # @param data
61
+ # Plain text.
62
+ # @return Secured data.
63
+ #
64
+ @classmethod
65
+ def encrypt(cls, p, data) -> bytearray:
66
+ if p.security != Security.NONE:
67
+ tmp = GXDLMSChippering.encryptAesGcm(p, data)
68
+ p.invocationCounter = p.invocationCounter + 1
69
+ return tmp
70
+ return data
71
+
72
+ def reset(self):
73
+ """
74
+ Reset encrypt settings.
75
+ """
76
+ self.security = Security.NONE
77
+ self.invocationCounter = 0
78
+
79
+ def isCiphered(self):
80
+ """
81
+ Is ciphering used.
82
+ """
83
+ return self.security != Security.NONE
84
+
85
+ #
86
+ # Generate GMAC password from given challenge.
87
+ # *
88
+ # @param challenge
89
+ # Client to Server or Server to Client challenge.
90
+ # @return Generated challenge.
91
+ #
92
+ def generateGmacPassword(self, challenge):
93
+ p = AesGcmParameter(0x10, self.systemTitle, self.blockCipherKey, self.authenticationKey)
94
+ p.security = Security.AUTHENTICATION
95
+ p.invocationCounter = self.invocationCounter
96
+ bb = GXByteBuffer()
97
+ GXDLMSChippering.encryptAesGcm(p, challenge)
98
+ bb.setUInt8(0x10)
99
+ bb.setUInt32(self.invocationCounter)
100
+ bb.set(p.countTag)
101
+ return bb.array()
102
+
103
+ def getSecurity(self):
104
+ """
105
+ Used security.
106
+ """
107
+ return self.security
108
+
109
+ def setSecurity(self, value):
110
+ """
111
+ Used security.
112
+ """
113
+ self.security = value
114
+
115
+ def getSystemTitle(self):
116
+ """
117
+ System title.
118
+ """
119
+ return self.systemTitle
120
+
121
+ #
122
+ # Recipient system Title.
123
+ #
124
+ def getRecipientSystemTitle(self):
125
+ """
126
+ Recipient system Title.
127
+ """
128
+ return self.recipientSystemTitle
129
+
130
+ def getBlockCipherKey(self):
131
+ # Block cipher key.
132
+ return self.blockCipherKey
133
+
134
+ def getAuthenticationKey(self):
135
+ # Authentication key.
136
+ return self.authenticationKey
137
+
138
+ def setAuthenticationKey(self, value):
139
+ # Authentication key.
140
+ self.authenticationKey = value
141
+
142
+ def getInvocationCounter(self):
143
+ # Invocation counter.
144
+ return self.invocationCounter
145
+
146
+ def getSecuritySuite(self):
147
+ # Used security suite.
148
+ return self.securitySuite
149
+
150
+ def getEphemeralKeyPair(self):
151
+ # Ephemeral key pair.
152
+ return self.ephemeralKeyPair
153
+
154
+ def setEphemeralKeyPair(self, value):
155
+ # Ephemeral key pair.
156
+ self.ephemeralKeyPair = value
157
+
158
+ def getKeyAgreementKeyPair(self):
159
+ # Client's key agreement key pair.
160
+ return self.keyAgreementKeyPair
161
+
162
+ def setKeyAgreementKeyPair(self, value):
163
+ # Client's key agreement key pair.
164
+ self.keyAgreementKeyPair = value
165
+
166
+ def getPublicKeys(self):
167
+ # Target (Server or client) Public key.
168
+ return self.publicKeys
169
+
170
+ def getCertificates(self):
171
+ # Available certificates.
172
+ return self.certificates
173
+
174
+ def getSigningKeyPair(self):
175
+ # Signing key pair.
176
+ return self.signingKeyPair
177
+
178
+ def setSigningKeyPair(self, value):
179
+ # Signing key pair.
180
+ self.signingKeyPair = value
181
+
182
+ def getSharedSecret(self):
183
+ # Shared secret is generated when connection is made.
184
+ return self.sharedSecret
185
+
186
+ def setSharedSecret(self, value):
187
+ # Shared secret is generated when connection is made.
188
+ self.sharedSecret = value
189
+
190
+ def getDedicatedKey(self):
191
+ # Dedicated key.
192
+ return self.dedicatedKey
193
+
194
+ def setDedicatedKey(self, value):
195
+ # Dedicated key.
196
+ self.dedicatedKey = value