def buffer(self): """ A Python buffer representing the underlying memory. The buffer may be passed to IO functions like this: `view.buffer = socket.recv(len(view.buffer))` """ return _ffi.buffer(self._data[0], self._size[0])
def asn1_from_ed25519_private_key(priv_key): """ Returns the ASN.1 encoding of a ED25519 private ket. :priv_key: an ED25519PrivateKey instance :returns: the ASN.1 encoding as a byte string """ encoded_len = _lib.xtt_asn1_private_key_length() encoded = _ffi.new('unsigned char[]', encoded_len) rc = _lib.xtt_asn1_from_ed25519_private_key(priv_key.native, encoded, len(encoded)) if rc == RC.SUCCESS: return _ffi.buffer(encoded)[:] else: raise error_from_code(rc)
def x509_from_ecdsap256_key_pair(pub_key, priv_key, common_name): """ Creates a self-signed x509 certificate for a common name and ECDSAP256 key pair. :pub_key: an ECDSAP256PublicKey instance :priv_key: an ECDSAP256PrivateKey instance :common_name: an XTTIdentity instance :returns: the certificate as a byte string """ cert_len = _lib.xtt_x509_certificate_length() cert = _ffi.new('unsigned char[]', cert_len) rc = _lib.xtt_x509_from_ecdsap256_keypair(pub_key.native, priv_key.native, common_name.native, cert, len(cert)) if rc == RC.SUCCESS: return _ffi.buffer(cert)[:] else: raise error_from_code(rc)
def data(self): return _ffi.buffer(self.native.data)[:]
def public_key(self): value = _lib.xtt_server_certificate_access_pubkey(self._raw) buff = _ffi.buffer(value, ED25519PublicKey.sizeof) return ED25519PublicKey(buff)
def root_id(self): value = _lib.xtt_server_certificate_access_rootid(self._raw) buff = _ffi.buffer(value, CertificateRootId.sizeof) return CertificateRootId(buff)
def expiry(self): value = _lib.xtt_server_certificate_access_expiry(self._raw) buff = _ffi.buffer(value, CertificateExpiry.sizeof) return CertificateExpiry(buff)
def id(self): value = _lib.xtt_server_certificate_access_id(self._raw) buff = _ffi.buffer(value, Identity.sizeof) return Identity(buff)