assistance-engine/docs/developer.avapframework.com/Ciphered_Nodes_EN.md

381 lines
7.2 KiB
Markdown

101OBeX offers the possibility of working with encrypted nodes or
projects. All services that are exposed through the API Manager can be
consumed in an encrypted manner, provided this preference is established
during project creation.
IT IS IMPORTANT TO UNDERSTAND THAT ONCE A PROJECT IS CREATED, THIS
ENCRYPTION SETTING CANNOT BE ALTERED. THEREFORE, IT IS CRITICAL TO
CAREFULLY CONSIDER WHETHER YOUR PROJECT REQUIRES ENCRYPTION TO AVOID
SUBSEQUENT DATA LOSS.
When you indicate that you want to be able to consume an encrypted
project, you will be assigned an encryption key for it (cipher
key) which can be consulted in the project data.
Once this key has been obtained, the calls can be encrypted under the
AES256 algorithm with said key and the response will be encrypted with the
same encryption key.
The nomenclature of the calls will be as follows:
The nomenclature of the calls will be as follows.
Decrypted call:
```javascript
https://api.101obex.com:8000/servicio?parameters
```
Encrypted call:
```javascript
https://api.101obex.com:5000/servicio?encripted_data=(encripted
parameters)
```
This adds an additional encryption layer that guarantees the security of
the transferred data.
The response will be encrypted and its morphology will be as detailed
below
Decrypted answer:
```javascript
{
"status"
:
true
,
"e_mail"
:
"test.user@waynnovate.com"
,
"elapsed"
:
0.18008685111999512
,
"datos_certificacion"
:
{
"codtran"
:
"0075f16df4b053a5d10502ffb01e9cd8"
}
,
"session_id"
:
"e9b7945dcbd5d18a6239acc7acafe8e9"
,
"type_of_user"
:
"impulso bu00e1sico"
,
"profile_id"
:
137
,
"code_profile"
:
"USUARIO"
,
"user_id"
:
50
,
"status"
:
null
,
"phone_lenght"
:
10
,
"menu"
:
[
[
"Acceso Ru00e1pido"
,
[
"Movements"
,
"movements"
,
false
]
,
[
"Add a card"
,
{' '}
"gestor_origenes_propios/crear"
,
false
]
,
[ {' '}
"Recharge cellphone minutes"
,
"Rechargecellphoneminutes"
,
false
]
,
[ {' '}
"Transfer between clients"
,
"moneysending"
,
false
]
,
[
"Request money"
,
"requestmoney"
,
false
]
,
[
"Services payment"
,
"payexpresspay"
,
false
]
]
]
,
"user_affiliate_id"
:
1
,
"currency"
:
"MXN"
,
"name"
:
"qwertyuio qwertyui"
,
"certificate"
:
false
,
"phone"
:
"9876543212"
}
```
Encrypted answer:
```javascript
{
"status"
:{' '}
true
,
"encrypted_data"
:{' '}
"k8DoQ9ADDph2o3oHdzeW0wO-FITgfGQD4xy9GcfuBtQy8IVazicD4J66kZ-HTlgWpCkXn7xlGDqCcXUNV
{' '}
TW9T7Ww1DpPXPyoilI2GPhOFliAWGpip_R56WVYr07qGmMUJy_n2I3si___hBb9MPEI3KBh9eupUO2gKDT
{' '}
bULimM_cpCtRHsqFdTZIpRedC0W_HdTgcCrZ_CItCoxAoyiCjx6knaH9dbaUV1GoywBWfuh3Dh4iqHGejH
{' '}
RbYi7Apm1PjCj5WNPEEN-UlfNj9hvurwTgCjBXilBg19ld3LUJj-1Yh48It_gLkna12ZqBiuUnQ3Rpj1hH
{' '}
vz7CkTjxStkigCyKA4lPh94cK_cJgaiv7c1Uyb54cB8N2bUTBhD4ojOSfR88bN-4wYiIEspinuKDmpHXO8
{' '}
HP_IgJSfgkU4QiTfbBKQ8u-2Hxe2x1JgbKIvjpiBNK0H3GNnaPrtciFf88EeQun5oZwOJiFtZBQHv-V4fd
{' '}
kfuOYBAWaOm13I9_PYiJir9BE145mIQOuugnebLASKju5UA-NHEclZ7fUF1fNyCeFxGW-6oYfadBanzpIM
{' '}
5PjRUODa92gF4X0pPcLy4v1jcegJSMSpTW0DH_vM14gV56OJ0Dvyf52OB2e3LDlfP7TwYmbY7YWwj5MpR1
{' '}
uoieOwbGsqbXqKvOOCmlwGIvAc-vowoTLRpviT1_fymNHyRqtb89Gjy_2rvsTgBLoZavKBOv5Wvu1Dil5u
{' '}
0wVzo7pqk5XV3lnTCi-t7kLiH7SfXtuIBhPQzPTO40btxpZwC2V4QBsx1BcBMs_cb7Kmcy53exgpQQQkRN
{' '}
bTU6jkSnTcccaCPzT9WGhxiHrS1U5bXXW4BM1j9aHFDjhBp6uT9_2QAh0oh-uljLTnw6r6KH69VFJyO2oK
{' '}
jG2Qttu-L95ynxW94ecMuLlU26O7F-j9IO1FpI-c8cfKAQs6tbUnv_cU49nTwpX5TZI1ZfCDOb042-KiCJ
{' '}
qOfP61FWZtEQrMw7VZwUxMylcku_In9caUUYgpvJhHwqE6GKdS0XuKEcGUV-tfMvBcnewCgobcZhIeTYKh
{' '}
KSoaA1AHR7IYHaf8U4isTCzcexJL_mnwHlvWGVEXmM2Ywy_y9Y6nIDFTXPsUG4aYjw="
}
```
Python code example to encrypt and decrypt (encryption key
highlighted)
```javascript
from Crypto
.Cipher{' '}
import AES
from Crypto
.Random{' '}
import new{' '}
as Random
from base64{' '}
import urlsafe_b64encode
, urlsafe_b64decode
class{' '}
CipherByAES
:
def{' '}
__init__
(self
)
:
self.block_size{' '}
={' '}
16
self.key{' '}
={' '}
'cedb3fb962255b1aafd033cabe831530'
self.pad{' '}
={' '}
lambda s
: s{' '}
+{' '}
(self
.block_size{' '}
-{' '}
len
(s
){' '}
% self
.block_size
){' '}
*
chr
(self
.block_size{' '}
-{' '}
len
(s
){' '}
% self
.block_size
)
self.unpad{' '}
={' '}
lambda s
: s
[
:
-
ord
(s
[
len
(s
){' '}
-{' '}
1
:
]
)
]
def{' '}
encrypt
(self
, data
)
:
plain_text = self
.pad
(data
)
iv = Random
(
)
.read
(AES
.block_size
)
cipher = AES
.new
(self
.key
, AES
.MODE_OFB
, iv
)
return urlsafe_b64encode
(iv{' '}
+ cipher
.encrypt
(plain_text
.encode
(
)
)
)
.decode
(
)
def{' '}
decrypt
(self
, data
)
:
cipher_text ={' '}
urlsafe_b64decode(data
.encode
(
)
)
iv = cipher_text
[
:self
.block_size
]
cipher = AES
.new
(self
.key
, AES
.MODE_OFB
, iv
)
return self
.unpad
(cipher
.decrypt
(cipher_text
[self
.block_size
]
)
)
.decode
(
)
```