Beispiel #1
0
 def _serializePrelude(self):
     writer = TlsStructureWriter(Tack.LENGTH - 64)
     writer.add(self.public_key.getRawKey(), 64)
     writer.add(self.min_generation, 1)
     writer.add(self.generation, 1)
     writer.add(self.expiration, 4)
     writer.add(self.target_hash, 32)
     return writer.getBytes()
Beispiel #2
0
    def serialize(self):
        w = TlsStructureWriter(self._getSerializedLength())

        if self.tacks:
            w.add(len(self.tacks) * Tack.LENGTH, 2)
            for tack in self.tacks:
                w.add(tack.serialize(), Tack.LENGTH)
        else:
            w.add(0, 2)

        w.add(self.activation_flags, 1)

        return w.getBytes()
Beispiel #3
0
 def serialize(self):
     """Return a bytearray containing the TACK_Break_Sig."""
     w = TlsStructureWriter(TackBreakSig.LENGTH)
     w.add(self.public_key.getRawKey(), 64)
     w.add(self.signature, 64)
     assert (w.index == len(w.bytes))
     return w.getBytes()
Beispiel #4
0
 def serialize(self):
     """Return a bytearray containing the TACK_Break_Sig."""
     w = TlsStructureWriter(TackBreakSig.LENGTH)
     w.add(self.public_key.getRawKey(), 64)
     w.add(self.signature, 64)
     assert(w.index == len(w.bytes))
     return w.getBytes()
Beispiel #5
0
 def _serializePreSig(self):
     writer = TlsStructureWriter(Tack.LENGTH - 64)
     writer.add(self.public_key.getRawKey(), 64)
     writer.add(self.min_generation, 1)
     writer.add(self.generation, 1)
     writer.add(self.expiration, 4)
     writer.add(self.target_hash, 32)
     return writer.getBytes()
Beispiel #6
0
    def serialize(self):
        w = TlsStructureWriter(self._getSerializedLength())

        if self.tack:
            w.add(Tack.LENGTH, 1)
            w.add(self.tack.serialize(), Tack.LENGTH)
        else:
            w.add(0, 1)

        if self.break_sigs:
            w.add(len(self.break_sigs) * TackBreakSig.LENGTH, 2)
            for break_sig in self.break_sigs:
                w.add(break_sig.serialize(), TackBreakSig.LENGTH)
        else:
            w.add(0, 2)

        w.add(self.pin_activation, 1)

        assert(w.index == len(w.bytes)) # did we fill entire bytearray?
        return w.getBytes()
Beispiel #7
0
 def serialize(self):
     w = TlsStructureWriter(TackKeyFile.LENGTH)
     w.add(self.version, 1)
     w.add(self.iter_count, 4)
     w.add(self.salt, 16)
     w.add(self.ciphertext, 32)
     w.add(self.public_key.getRawKey(), 64)
     w.add(self.mac, 32)
     return w.getBytes()
Beispiel #8
0
 def serialize(self):
     w = TlsStructureWriter(TackKeyFile.LENGTH)
     w.add(self.version, 1)
     w.add(self.iter_count, 4)
     w.add(self.salt, 16)
     w.add(self.ciphertext, 32)
     w.add(self.public_key.getRawKey(), 64)
     w.add(self.mac, 32)
     return w.getBytes()
Beispiel #9
0
 def serialize(self, extenderFormat=False):
     assert (self.tacks)
     w = TlsStructureWriter(self._getSerializedLength(extenderFormat))
     if extenderFormat:
         w.add(62208, 2)
         w.add(len(self.tacks) * Tack.LENGTH + 3, 2)
     w.add(len(self.tacks) * Tack.LENGTH, 2)
     for tack in self.tacks:
         w.add(tack.serialize(), Tack.LENGTH)
     w.add(self.activation_flags, 1)
     return w.getBytes()
Beispiel #10
0
    def serialize(self):
        w = TlsStructureWriter(self._getSerializedLength())

        if self.tack:
            w.add(Tack.LENGTH, 1)
            w.add(self.tack.serialize(), Tack.LENGTH)
        else:
            w.add(0, 1)

        if self.break_sigs:
            w.add(len(self.break_sigs) * TackBreakSig.LENGTH, 2)
            for break_sig in self.break_sigs:
                w.add(break_sig.serialize(), TackBreakSig.LENGTH)
        else:
            w.add(0, 2)

        w.add(self.pin_activation, 1)

        return w.getBytes()
Beispiel #11
0
 def serialize(self):
     writer = TlsStructureWriter(64)
     writer.add(self.signature, 64)
     return self._serializePrelude() + writer.getBytes()
Beispiel #12
0
    def serialize(self):
        w = TlsStructureWriter(TackKeyFile.LENGTH)
        w.add(self.version, 1)
        w.add(self.iter_count, 4)
        w.add(self.salt, 16)
        w.add(self.ciphertext, 32)
        w.add(self.public_key.getRawKey(), 64)
        w.add(self.mac, 32)
        assert (w.index == len(w.bytes))  # did we fill entire bytearray?

        return w.getBytes()
Beispiel #13
0
 def serialize(self, extenderFormat=False):
     assert(self.tacks)
     w = TlsStructureWriter(self._getSerializedLength(extenderFormat))
     if extenderFormat:
         w.add(62208, 2)
         w.add(len(self.tacks) * Tack.LENGTH + 3, 2)
     w.add(len(self.tacks) * Tack.LENGTH, 2)
     for tack in self.tacks:
         w.add(tack.serialize(), Tack.LENGTH)
     w.add(self.activation_flags, 1)
     return w.getBytes()
Beispiel #14
0
    def serialize(self):
        w = TlsStructureWriter(self._getSerializedLength())

        if self.tacks:
            w.add(len(self.tacks) * Tack.LENGTH, 2)
            for tack in self.tacks:
                w.add(tack.serialize(), Tack.LENGTH)
        else:
            w.add(0, 2)

        w.add(self.activation_flags, 1)

        return w.getBytes()
Beispiel #15
0
    def serialize(self):
        w = TlsStructureWriter(TackKeyFile.LENGTH)
        w.add(self.version, 1)
        w.add(self.iter_count, 4)
        w.add(self.salt, 16)
        w.add(self.ciphertext, 32)
        w.add(self.public_key.getRawKey(), 64)
        w.add(self.mac, 32)
        assert(w.index == len(w.bytes)) # did we fill entire bytearray?

        return w.getBytes()