コード例 #1
0
ファイル: secrets.py プロジェクト: JHUAPL/PyKMIP
class KeyBlockKey(Struct):

    def __init__(self, key_block=None, tag=Tags.DEFAULT):
        super(KeyBlockKey, self).__init__(tag)
        self.key_block = key_block
        self.validate()

    def read(self, istream):
        super(KeyBlockKey, self).read(istream)
        tstream = BytearrayStream(istream.read(self.length))

        self.key_block = KeyBlock()
        self.key_block.read(tstream)

        self.is_oversized(tstream)
        self.validate()

    def write(self, ostream):
        tstream = BytearrayStream()

        self.key_block.write(tstream)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(KeyBlockKey, self).write(ostream)
        ostream.write(tstream.buffer)

    def validate(self):
        self.__validate()

    def __validate(self):
        # TODO (peter-hamilton) Finish implementation.
        pass
コード例 #2
0
ファイル: secrets.py プロジェクト: xxgoracle/PyKMIP
class KeyBlockKey(Struct):

    def __init__(self, key_block=None, tag=Tags.DEFAULT):
        super(KeyBlockKey, self).__init__(tag)
        self.key_block = key_block
        self.validate()

    def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0):
        super(KeyBlockKey, self).read(istream, kmip_version=kmip_version)
        tstream = BytearrayStream(istream.read(self.length))

        self.key_block = KeyBlock()
        self.key_block.read(tstream, kmip_version=kmip_version)

        self.is_oversized(tstream)
        self.validate()

    def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
        tstream = BytearrayStream()

        self.key_block.write(tstream, kmip_version=kmip_version)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(KeyBlockKey, self).write(ostream, kmip_version=kmip_version)
        ostream.write(tstream.buffer)

    def validate(self):
        self.__validate()

    def __validate(self):
        # TODO (peter-hamilton) Finish implementation.
        pass
コード例 #3
0
ファイル: secrets.py プロジェクト: cactorium/PyKMIP
class SecretData(Struct):

    class SecretDataType(Enumeration):
        ENUM_TYPE = enums.SecretDataType

        def __init__(self, value=None):
            super(SecretData.SecretDataType, self).__init__(
                value, Tags.SECRET_DATA_TYPE)

    def __init__(self,
                 secret_data_type=None,
                 key_block=None):
        super(SecretData, self).__init__(Tags.SECRET_DATA)
        self.secret_data_type = secret_data_type
        self.key_block = key_block
        self.validate()

    def read(self, istream):
        super(SecretData, self).read(istream)
        tstream = BytearrayStream(istream.read(self.length))

        self.secret_data_type = SecretData.SecretDataType()
        self.key_block = KeyBlock()

        self.secret_data_type.read(tstream)
        self.key_block.read(tstream)

        self.is_oversized(tstream)
        self.validate()

    def write(self, ostream):
        tstream = BytearrayStream()

        self.secret_data_type.write(tstream)
        self.key_block.write(tstream)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(SecretData, self).write(ostream)
        ostream.write(tstream.buffer)

    def validate(self):
        self.__validate()

    def __validate(self):
        # TODO (peter-hamilton) Finish implementation.
        pass
コード例 #4
0
ファイル: secrets.py プロジェクト: xxgoracle/PyKMIP
class SecretData(Struct):

    class SecretDataType(Enumeration):

        def __init__(self, value=None):
            super(SecretData.SecretDataType, self).__init__(
                enums.SecretDataType, value, Tags.SECRET_DATA_TYPE)

    def __init__(self,
                 secret_data_type=None,
                 key_block=None):
        super(SecretData, self).__init__(Tags.SECRET_DATA)
        self.secret_data_type = secret_data_type
        self.key_block = key_block
        self.validate()

    def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0):
        super(SecretData, self).read(istream, kmip_version=kmip_version)
        tstream = BytearrayStream(istream.read(self.length))

        self.secret_data_type = SecretData.SecretDataType()
        self.key_block = KeyBlock()

        self.secret_data_type.read(tstream, kmip_version=kmip_version)
        self.key_block.read(tstream, kmip_version=kmip_version)

        self.is_oversized(tstream)
        self.validate()

    def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
        tstream = BytearrayStream()

        self.secret_data_type.write(tstream, kmip_version=kmip_version)
        self.key_block.write(tstream, kmip_version=kmip_version)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(SecretData, self).write(ostream, kmip_version=kmip_version)
        ostream.write(tstream.buffer)

    def validate(self):
        self.__validate()

    def __validate(self):
        # TODO (peter-hamilton) Finish implementation.
        pass
コード例 #5
0
ファイル: secrets.py プロジェクト: JHUAPL/PyKMIP
class SplitKey(Struct):

    class SplitKeyParts(Integer):

        def __init__(self, value=None):
            super(SplitKey.SplitKeyParts, self).__init__(
                value, Tags.SPLIT_KEY_PARTS)

    class KeyPartIdentifier(Integer):

        def __init__(self, value=None):
            super(SplitKey.KeyPartIdentifier, self).__init__(
                value, Tags.KEY_PART_IDENTIFIER)

    class SplitKeyThreshold(Integer):

        def __init__(self, value=None):
            super(SplitKey.SplitKeyThreshold, self).__init__(
                value, Tags.SPLIT_KEY_THRESHOLD)

    class SplitKeyMethod(Enumeration):

        def __init__(self, value=None):
            super(SplitKey.SplitKeyMethod, self).__init__(
                enums.SplitKeyMethod, value, Tags.SPLIT_KEY_METHOD)

    class PrimeFieldSize(BigInteger):

        def __init__(self, value=None):
            super(SplitKey.PrimeFieldSize, self).__init__(
                value, Tags.PRIME_FIELD_SIZE)

    def __init__(self,
                 split_key_parts=None,
                 key_part_identifier=None,
                 split_key_threshold=None,
                 split_key_method=None,
                 prime_field_size=None,
                 key_block=None):
        super(SplitKey, self).__init__(Tags.SPLIT_KEY)
        self.split_key_parts = split_key_parts
        self.key_part_identifier = key_part_identifier
        self.split_key_threshold = split_key_threshold
        self.split_key_method = split_key_method
        self.prime_field_size = prime_field_size
        self.key_block = key_block
        self.validate()

    def read(self, istream):
        super(SplitKey, self).read(istream)
        tstream = BytearrayStream(istream.read(self.length))

        self.split_key_parts = SplitKey.SplitKeyParts()
        self.split_key_parts.read(tstream)

        self.key_part_identifier = SplitKey.KeyPartIdentifier()
        self.key_part_identifier.read(tstream)

        self.split_key_threshold = SplitKey.SplitKeyThreshold()
        self.split_key_threshold.read(tstream)

        if self.is_tag_next(Tags.PRIME_FIELD_SIZE, tstream):
            self.prime_field_size = SplitKey.PrimeFieldSize()
            self.prime_field_size.read(tstream)

        self.key_block = KeyBlock()
        self.key_block.read(tstream)

        self.is_oversized(tstream)
        self.validate()

    def write(self, ostream):
        tstream = BytearrayStream()

        self.split_key_parts.write(tstream)
        self.key_part_identifier.write(tstream)
        self.split_key_threshold.write(tstream)
        self.split_key_method.write(tstream)

        if self.prime_field_size is not None:
            self.prime_field_size.write(tstream)

        self.key_block.write(tstream)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(SplitKey, self).write(ostream)
        ostream.write(tstream.buffer)

    def validate(self):
        self.__validate()

    def __validate(self):
        # TODO (peter-hamilton) Finish implementation.
        pass
コード例 #6
0
ファイル: secrets.py プロジェクト: vbnmmnbv/PyKMIP
class SplitKey(Struct):
    class SplitKeyParts(Integer):
        def __init__(self, value=None):
            super(SplitKey.SplitKeyParts,
                  self).__init__(value, Tags.SPLIT_KEY_PARTS)

    class KeyPartIdentifier(Integer):
        def __init__(self, value=None):
            super(SplitKey.KeyPartIdentifier,
                  self).__init__(value, Tags.KEY_PART_IDENTIFIER)

    class SplitKeyThreshold(Integer):
        def __init__(self, value=None):
            super(SplitKey.SplitKeyThreshold,
                  self).__init__(value, Tags.SPLIT_KEY_THRESHOLD)

    class SplitKeyMethod(Enumeration):
        def __init__(self, value=None):
            super(SplitKey.SplitKeyMethod,
                  self).__init__(enums.SplitKeyMethod, value,
                                 Tags.SPLIT_KEY_METHOD)

    class PrimeFieldSize(BigInteger):
        def __init__(self, value=None):
            super(SplitKey.PrimeFieldSize,
                  self).__init__(value, Tags.PRIME_FIELD_SIZE)

    def __init__(self,
                 split_key_parts=None,
                 key_part_identifier=None,
                 split_key_threshold=None,
                 split_key_method=None,
                 prime_field_size=None,
                 key_block=None):
        super(SplitKey, self).__init__(Tags.SPLIT_KEY)
        self.split_key_parts = split_key_parts
        self.key_part_identifier = key_part_identifier
        self.split_key_threshold = split_key_threshold
        self.split_key_method = split_key_method
        self.prime_field_size = prime_field_size
        self.key_block = key_block
        self.validate()

    def read(self, istream):
        super(SplitKey, self).read(istream)
        tstream = BytearrayStream(istream.read(self.length))

        self.split_key_parts = SplitKey.SplitKeyParts()
        self.split_key_parts.read(tstream)

        self.key_part_identifier = SplitKey.KeyPartIdentifier()
        self.key_part_identifier.read(tstream)

        self.split_key_threshold = SplitKey.SplitKeyThreshold()
        self.split_key_threshold.read(tstream)

        if self.is_tag_next(Tags.PRIME_FIELD_SIZE, tstream):
            self.prime_field_size = SplitKey.PrimeFieldSize()
            self.prime_field_size.read(tstream)

        self.key_block = KeyBlock()
        self.key_block.read(tstream)

        self.is_oversized(tstream)
        self.validate()

    def write(self, ostream):
        tstream = BytearrayStream()

        self.split_key_parts.write(tstream)
        self.key_part_identifier.write(tstream)
        self.split_key_threshold.write(tstream)
        self.split_key_method.write(tstream)

        if self.prime_field_size is not None:
            self.prime_field_size.write(tstream)

        self.key_block.write(tstream)

        # Write the length and value of the template attribute
        self.length = tstream.length()
        super(SplitKey, self).write(ostream)
        ostream.write(tstream.buffer)

    def validate(self):
        self.__validate()

    def __validate(self):
        # TODO (peter-hamilton) Finish implementation.
        pass