Beispiel #1
0
	def _secureReplaceKey(self, slot, newKey):
		partitionId = self._getPartitionIdForSlot(slot)
		self.log.debug('SECURE replacing key in slot: {} in partition: {}'.format(slot, partitionId))
		if (0 == partitionId):
			oldPartitionKey = self._getMasterKey()
			newPartitionKey = self._getMasterKey()
		else:
			oldPartitionKey = self._getKeyFromCascade(partitionId)
			newPartitionKey = CryptoLib.generateRandomKey()

		partition = self.getPartition(partitionId, oldPartitionKey)

		localSlot = self._slotToLocalSlot(slot)
		partition.setKey(localSlot, newKey)

		self.storePartition(partition, newPartitionKey)

		if (0 == partitionId):
			# print('Replaced master key with: {}'.format(newPartitionKey))
			pass
		else:
			self._secureReplaceKey(partitionId, newPartitionKey)
Beispiel #2
0
 def getObject(self, name):
     key = CryptoLib.digestKeyString('keeey')
     c = self.si.getObject(container=self.containerName, name=name)
     return DataCrypt.DataCrypt(key).decryptBytesIO(ciphertext=c)
Beispiel #3
0
 def putObject(self, o, name):
     key = CryptoLib.digestKeyString('keeey')
     c = DataCrypt.DataCrypt(key).encryptBytesIO(plaintext=o)
     self.si.putObject(self.containerName, name, c)
Beispiel #4
0
	def _getMasterKey(self):
		return CryptoLib.digestKeyString('MASTERKEY')
Beispiel #5
0
	def generateKey(self, slot):
		if (self.EMPTY_KEY != self.keys[slot]):
			raise SystemError('requested generate key but slot is not empty')
		key = CryptoLib.generateRandomKey()
		self.setKey(slot, key)
		return key
Beispiel #6
0
	def getObject(self, name):
		key = CryptoLib.digestKeyString('keeey')
		c = self.si.getObject(container=self.containerName, name=name)
		return DataCrypt.DataCrypt(key).decryptBytesIO(ciphertext=c)
Beispiel #7
0
	def putObject(self, o, name):
		key = CryptoLib.digestKeyString('keeey')
		c = DataCrypt.DataCrypt(key).encryptBytesIO(plaintext=o)
		self.si.putObject(self.containerName, name, c)