How to use the ledgerblue.deployed.getDeployedSecretV1 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 / loadApp.py View on Github external
cleardata_block_len=None
	if args.appFlags & 2:
		# 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([])
github LedgerHQ / blue-loader-python / ledgerblue / deleteApp.py View on Github external
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 = 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([])
github LedgerHQ / blue-loader-python / ledgerblue / listApps.py View on Github external
args = get_argparser().parse_args()

	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)