Skip to content

crypto_box_open,crypto_box_open_easy #137

@zhangxinguo1491625

Description

@zhangxinguo1491625

crypto_box_open_easy() and crypto_box_open() in libsodium seem to be different。
企业微信截图_eb11d952-87b8-4c5d-b8d1-5bd861e1624b

`def inttobytes(param_int_list):
param_hex = ""
for param_int in param_int_list:
if param_int<0:
param_int = param_int + 256
if len(hex(param_int)[2:])==1:
param_hex = param_hex + "0" + hex(param_int)[2:]
else:
param_hex = param_hex + hex(param_int)[2:]
return bytes.fromhex(param_hex)

def bytesToString(bs):
return bytes.decode(bs,encoding='utf8')

privateKey_int_list = [-42,23,-8,-49,68,59,-86,57,124,-34,-56,90,44,-103,-48,115,-94,57,-32,-53,40,-82,7,-66,-15,-83,72,25,-14,105,95,-61]
privateKey = base64.b64decode("1hf4z0Q7qjl83shaLJnQc6I54Msorge+8a1IGfJpX8M=")
publickey_int_list = [95,73,-2,-73,63,-78,-1,41,-103,73,125,-8,-78,122,-5,-124,36,-23,9,-125,38,-81,-63,3,-63,26,-12,-33,120,60,-23,36]
publickey = inttobytes(publickey_int_list)
bArr2_int_hex= [-41,-81,-73,-39,-40,106,-127,82,5,118,83,-128,-121,-81,-17,63,-121,6,108,-81,-99,75,93,105,-74,22,21,67,72,-101,110,108,55,-60,-64,-115,-4,-49,15,80,-95,51,98,31,-1,7,86,78,-27,-128,-78,-74,-86,-78,123,28,-126,-41,-76,97,51,-11,122,65,-80,-80,-114,-90,13,-55,-101,89,-112,-7,-31,64,92,61,-111,49,-35,-120,110,-6,-26,107,61,5,88,57,75,-102,18,-104,120,15,-124,58,19,-9,-12,-45,-22,14,42,-51,-90,39,-109,-70,89,53,-80,-19,-55,-93,-42,29,-46,-116,-96,-8,33,1,-9,-68,-119,-116,34,-78,-54,-29,-6,-100,-74,33,-89,-87,6,-8,43,-74,75,8,-57,-9,12,25,60,67,52,32,53,54,59,107,38,85,-83,-45,-1,32,93,-11,-17,-19,-41,116,-56,74,70,10,-70,20,-119,-113,55,80,-98,31,-99,-36,88,114,72,-40,75,116,44,-65,92,-61,106,88,121,-79,-18,-33,-73,-86,-13,-33,19,125,71,2,104,-16,-23,72,-91,-75,-54,-3,-63,111,69,87,24,10,19,-108,-111,-21,118,-51,20,98,-54,44,-59,-110,69,77,14,-70,40,80,-31,-50,43,-82,-11,-2,-96,-89,101,34,-8,54,-5,-86,-31,19,25,123,-106,-23,105,73,-26,-61,118,-111,37,108,114,77,-43,-50,83,76,-71,-55,65,9,90,-115,121,-81,-51,88,89,-29,-97,5,-46,-21,-59,33,-51,34,-27,18,95,65,-98,-68,86,-65,-96,91,-86,52,-33,-26,-121,-63,68,-41,-114,125,62,62,39,-51,85,95,-90,-8,77]
bArr2 = inttobytes(bArr2_int_hex)
bArr3_int_hex = [106,112,-58,-70,28,-71,45,-121,65,24,13,48,96,39,79,-15,37,-73,125,-6,120,-78,-54,-111]
bArr3 = inttobytes(bArr3_int_hex)
i = 321
bArr_int_hex = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
bArr = inttobytes(bArr_int_hex)
print(libnacl.crypto_box_open_easy(bArr2,bArr3,publickey,privateKey))`

When I change crypto_box_open in the picture to crypto_box_open_easy, no Crypterror will be reported

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions