i.mx8mq DRM

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

i.mx8mq DRM

1,216件の閲覧回数
i_MX51
Contributor II

您好

在下面的code當中,在ubuntu16.04下使用python3去build 會有問題(python2也是不行的)

請問我要bulidt 成 level 1,相信這是很重要的步驟,可以請您回覆我?

謝謝

#!/usr/bin/env python3

from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
from argparse import FileType

import argparse
parser = argparse.ArgumentParser(description='Provisioning encryption tool.')
parser.add_argument('key', type = file)
parser.add_argument('plaintext', type = file)
parser.add_argument('ciphertext', type = argparse.FileType('w'))
parser.add_argument('nonce', type = argparse.FileType('w'))
parser.add_argument('tag', type = argparse.FileType('w'))
args = parser.parse_args()

data = args.plaintext.read()
key = args.key.read()
nonce = get_random_bytes(7)

data += '\0' * (((len(data)+15)/16 * 16) - len(data))

cipher = AES.new(key, AES.MODE_CCM, nonce)
ciphertext, tag = cipher.encrypt_and_digest(data)

cipher = AES.new(key, AES.MODE_CCM, nonce)
plaintext = cipher.decrypt_and_verify(ciphertext, tag)

if (plaintext != data):
print ("Encryption error.")
else:
args.nonce.write(nonce)
args.tag.write(tag)
args.ciphertext.write(ciphertext)
print ("ncryption done. ")

0 件の賞賛
返信
1 返信

1,179件の閲覧回数
jimmychan
NXP TechSupport
NXP TechSupport

Could you tell me more information about your issue?

Which version of BSP are you using?

Is there any error message?

0 件の賞賛
返信