How to use the ledgerblue.deployed.getDeployedSecretV2 function in ledgerblue

To help you get started, we’ve selected a few ledgerblue examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LedgerHQ / blue-loader-python / ledgerblue / mcuBootloader.py View on Github external
import binascii
	import sys

	args = get_argparser().parse_args()

	if args.targetId == None:
		args.targetId = 0x31000002
	if args.rootPrivateKey == None:
		privateKey = PrivateKey()
		publicKey = binascii.hexlify(privateKey.pubkey.serialize(compressed=False))
		print("Generated random root public key : %s" % publicKey)
		args.rootPrivateKey = privateKey.serialize()

	dongle = getDongle(args.apdu)

	secret = getDeployedSecretV2(dongle, bytearray.fromhex(args.rootPrivateKey), args.targetId)
	loader = HexLoader(dongle, 0xe0, True, secret)
	loader.exchange(0xE0, 0, 0, 0, loader.encryptAES(b'\xB0'));
github LedgerHQ / blue-loader-python / ledgerblue / listApps.py View on Github external
dongle = getDongle(args.apdu)

	if args.scp:
		if args.targetId is None:
			args.targetId = 0x31000002
		if args.rootPrivateKey is None:
			privateKey = PrivateKey()
			publicKey = binascii.hexlify(privateKey.pubkey.serialize(compressed=False))
			print("Generated random root public key : %s" % publicKey)
			args.rootPrivateKey = privateKey.serialize()


		if args.deployLegacy:
			secret = getDeployedSecretV1(dongle, bytearray.fromhex(args.rootPrivateKey), args.targetId)
		else:
			secret = getDeployedSecretV2(dongle, bytearray.fromhex(args.rootPrivateKey), args.targetId)
	else:
		secret = None
	loader = HexLoader(dongle, 0xe0, args.scp, secret)
	apps = loader.listApp()
	while len(apps) != 0:
		print(apps)
		apps = loader.listApp(False)
github LedgerHQ / blue-loader-python / ledgerblue / resetCustomCA.py View on Github external
import sys

	args = get_argparser().parse_args()

	if args.targetId is None:
		args.targetId = 0x31000002
	if args.rootPrivateKey is None:
		privateKey = PrivateKey()
		publicKey = binascii.hexlify(privateKey.pubkey.serialize(compressed=False))
		print("Generated random root public key : %s" % publicKey)
		args.rootPrivateKey = privateKey.serialize()


	dongle = getDongle(args.apdu)

	secret = getDeployedSecretV2(dongle, bytearray.fromhex(args.rootPrivateKey), args.targetId)
	loader = HexLoader(dongle, 0xe0, True, secret)

	loader.resetCustomCA()
github LedgerHQ / blue-loader-python / ledgerblue / loadApp.py View on Github external
# Not true for scp < 3
		# if signature is None:
		# 	raise BaseException('Upgrades must be signed')

		# ensure data can be decoded with code decryption key without troubles.
		cleardata_block_len = 16

	dongle = None
	secret = None
	if not args.offline:
		dongle = getDongle(args.apdu)

		if args.deployLegacy:
			secret = getDeployedSecretV1(dongle, bytearray.fromhex(args.rootPrivateKey), args.targetId)
		else:
			secret = getDeployedSecretV2(dongle, bytearray.fromhex(args.rootPrivateKey), args.targetId)
	else:
		fileTarget = open(args.offline, "wb")
		class FileCard():
			def __init__(self, target):
				self.target = target
			def exchange(self, apdu):
				if (args.apdu):
					print(binascii.hexlify(apdu))
				apdu = binascii.hexlify(apdu)
				if sys.version_info.major == 2:
					self.target.write(str(apdu) + '\n')
				else:
					self.target.write(apdu + '\n'.encode())
				return bytearray([])
			def apduMaxDataSize(self):
				# ensure to allow for encryption of those apdu afterward
github LedgerHQ / blue-loader-python / ledgerblue / deleteApp.py View on Github external
args.targetId = 0x31000002
	if args.rootPrivateKey == None:
		privateKey = PrivateKey()
		publicKey = binascii.hexlify(privateKey.pubkey.serialize(compressed=False))
		print("Generated random root public key : %s" % publicKey)
		args.rootPrivateKey = privateKey.serialize()

	dongle = None
	secret = None
	if not args.offline:
		dongle = getDongle(args.apdu)

		if args.deployLegacy:
			secret = getDeployedSecretV1(dongle, bytearray.fromhex(args.rootPrivateKey), args.targetId)
		else:
			secret = getDeployedSecretV2(dongle, bytearray.fromhex(args.rootPrivateKey), args.targetId)
	else:
		fileTarget = open(args.offline, "wb")
		class FileCard():
			def __init__(self, target):
				self.target = target
			def exchange(self, apdu):
				if (args.apdu):
					print(binascii.hexlify(apdu))
				apdu = binascii.hexlify(apdu)
				if sys.version_info.major == 2:
					self.target.write(str(apdu) + '\n')
				else:
					self.target.write(apdu + '\n'.encode())
				return bytearray([])
			def apduMaxDataSize(self):
				# ensure to allow for encryption of those apdu afterward
github LedgerHQ / blue-loader-python / ledgerblue / runScript.py View on Github external
def __init__(self, dongle, targetId, rootPrivateKey):
			secret = getDeployedSecretV2(dongle, rootPrivateKey, targetId)
			self.loader = HexLoader(dongle, 0xe0, True, secret)
github LedgerHQ / blue-loader-python / ledgerblue / setupCustomCA.py View on Github external
if args.rootPrivateKey is None:
		privateKey = PrivateKey()
		publicKey = binascii.hexlify(privateKey.pubkey.serialize(compressed=False))
		print("Generated random root public key : %s" % publicKey)
		args.rootPrivateKey = privateKey.serialize()
	if args.public is None:
		raise Exception("Missing public key")
	if args.name is None:
		raise Exception("Missing certificate name")

	public = bytearray.fromhex(args.public)


	dongle = getDongle(args.apdu)

	secret = getDeployedSecretV2(dongle, bytearray.fromhex(args.rootPrivateKey), args.targetId)
	loader = HexLoader(dongle, 0xe0, True, secret)

	loader.setupCustomCA(args.name, public)