Esempio n. 1
0
    def readMeta(self):
        self.open()
        try:
            #a = self.application()
            #if a.header.titleId:
            #	self.titleId = a.header.titleId
            #	self.title().setRightsId(a.header.rightsId)

            t = self.ticket()
            rightsId = hx(t.getRightsId().to_bytes(
                0x10, byteorder='big')).decode('utf-8').upper()
            self.titleId = rightsId[0:16]
            self.title().setRightsId(rightsId)
            Print.info('rightsId = ' + rightsId)

            titleKey = t.getTitleKeyBlock()
            titleKeyStr = format(titleKey, 'X').zfill(32)
            if titleKey != 0 and blockchain.verifyKey(self.titleId,
                                                      titleKeyStr):
                Print.info(self.titleId + ' key = ' + titleKeyStr)
                self.title().setKey(titleKeyStr)
                self.setHasValidTicket(True)
        except BaseException as e:
            Print.info('readMeta filed ' + self.path + ", " + str(e))
            raise
        self.close()
Esempio n. 2
0
    def printInfo(self, maxDepth=3, indent=0):
        tabs = '\t' * indent

        rightsId = format(self.getRightsId(), 'X').zfill(32)
        titleId = rightsId[0:16]
        titleKey = format(self.getTitleKeyBlock(), 'X').zfill(32)

        Print.info('\n%sTicket\n' % (tabs))
        super(Ticket, self).printInfo(maxDepth, indent)
        Print.info(tabs + 'signatureType = ' + str(self.signatureType))
        Print.info(tabs + 'keyType = ' + str(self.keyType))
        Print.info(tabs + 'masterKeyRev = ' + str(self.masterKeyRevision))
        Print.info(tabs + 'ticketId = ' + str(self.ticketId))
        Print.info(tabs + 'deviceId = ' + str(self.deviceId))
        Print.info(tabs + 'rightsId = ' + rightsId)
        Print.info(tabs + 'accountId = ' + str(self.accountId))
        Print.info(tabs + 'titleId = ' + titleId)
        Print.info(tabs + 'titleKey = ' + titleKey)
        Print.info(tabs + 'titleKeyDec = ' + str(
            hx(
                Keys.decryptTitleKey(
                    (self.getTitleKey()), self.masterKeyRevision))))

        try:
            if blockchain.verifyKey(titleId, titleKey):
                tkeyStatus = 'VERIFIED'
            else:
                tkeyStatus = 'BAD KEY'
        except BaseException as e:
            tkeyStatus = 'UNKNOWN - ' + str(e)
            raise

        Print.info(tabs + 'titleKeyStatus = ' + tkeyStatus)
Esempio n. 3
0
def unlockAll():
    nut.initTitles()
    nut.initFiles()

    for k, f in Nsps.files.items():
        if f.isUnlockable():
            try:
                if not blockchain.verifyKey(f.titleId, f.title().key):
                    raise IOError('Could not verify title key! %s / %s - %s' %
                                  (f.titleId, f.title().key, f.title().name))
                    continue
                Print.info('unlocking ' + f.path)
                f.open(f.path, 'r+b')
                f.unlock()
                f.close()
            except BaseException as e:
                Print.info('error unlocking: ' + str(e))
Esempio n. 4
0
def submitKeys():
	for id, t in Titles.items():
		if t.key and len(t.getFiles()) > 0:
			try:
				#blockchain.blockchain.suggest(t.id, t.key)
				if not blockchain.verifyKey(t.id, t.key):
					Print.error('Key verification failed for %s / %s' % (str(t.id), str(t.key)))
					for f in t.getFiles():
						f.hasValidTicket = False
						f.move()
			except LookupError as e:
				Print.info(str(e))
			except OSError as e:
				Print.info(str(e))
			except BaseException as e:
				Print.info(str(e))
				raise
Esempio n. 5
0
File: nut.py Progetto: blawar/nut
                            Print.info('good file: ' + str(path))
                            bf.write('good file: %s\n' % str(path))
                            f.close()
                        except:
                            f.close()
                            Print.error('bad file: ' + str(path))
                            bf.write('bad file: %s\n' % str(path))

                        s.add()
                    s.close()
                Nsps.save()

            if args.verify_title_key:
                nut.initTitles()
                nut.initFiles()
                if blockchain.verifyKey(args.verify[0], args.verify[1]):
                    Print.info('Title key is valid')
                else:
                    Print.info('Title key is INVALID %s - %s' %
                               (args.verify[0], args.verify[1]))

            if args.restore:
                nut.initTitles()
                nut.initFiles()
                prev = Config.extractVersion
                Config.extractVersion = True

                for path in expandFiles(args.file):
                    try:
                        f = Fs.factory(str(path))
                        f.setPath(str(path))