Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 4
0
	def _getMasterKey(self):
		return CryptoLib.digestKeyString('MASTERKEY')
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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)