/usr/lib/python3/dist-packages/axolotl/groups/state/senderkeyrecord.py is in python3-axolotl 0.1.39-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | # -*- coding: utf-8 -*-
from ...state.storageprotos_pb2 import SenderKeyRecordStructure
from .senderkeystate import SenderKeyState
from ...invalidkeyidexception import InvalidKeyIdException
class SenderKeyRecord:
def __init__(self, serialized=None):
self.senderKeyStates = []
if serialized:
senderKeyRecordStructure = SenderKeyRecordStructure()
senderKeyRecordStructure.ParseFromString(serialized)
for structure in senderKeyRecordStructure.senderKeyStates:
self.senderKeyStates.append(SenderKeyState(senderKeyStateStructure=structure))
def isEmpty(self):
return len(self.senderKeyStates) == 0
def getSenderKeyState(self, keyId=None):
if keyId is None:
if len(self.senderKeyStates):
return self.senderKeyStates[0]
else:
raise InvalidKeyIdException("No key state in record")
else:
for state in self.senderKeyStates:
if state.getKeyId() == keyId:
return state
raise InvalidKeyIdException("No keys for: %s" % keyId)
def addSenderKeyState(self, id, iteration, chainKey, signatureKey):
"""
:type id: int
:type iteration: int
:type chainKey: bytearray
:type signatureKey: ECPublicKey
"""
self.senderKeyStates.append(SenderKeyState(id, iteration, chainKey, signatureKey))
def setSenderKeyState(self, id, iteration, chainKey, signatureKey):
"""
:type id: int
:type iteration: int
:type chainKey: bytearray
:type signatureKey: ECKeyPair
"""
del self.senderKeyStates[:]
self.senderKeyStates.append(SenderKeyState(id, iteration, chainKey, signatureKeyPair=signatureKey))
def serialize(self):
recordStructure = SenderKeyRecordStructure()
for senderKeyState in self.senderKeyStates:
recordStructure.senderKeyStates.extend([senderKeyState.getStructure()])
return recordStructure.SerializeToString()
|