An asn1crypto.keys.PublicKeyInfo or oscrypto.asymmetric.PublicKey
        object of the subject's public key.
18449
def subject_public_key(self, value):
        

        is_oscrypto = isinstance(value, asymmetric.PublicKey)
        if not isinstance(value, keys.PublicKeyInfo) and not is_oscrypto:
            raise TypeError(_pretty_message(
                '''
                subject_public_key must be an instance of
                asn1crypto.keys.PublicKeyInfo or oscrypto.asymmetric.PublicKey,
                not %s
                ''',
                _type_name(value)
            ))

        if is_oscrypto:
            value = value.asn1

        self._subject_public_key = value

        self._key_identifier = self._subject_public_key.sha1
        self._authority_key_identifier = None
309403
private ObjectMetadata toObjectMetadata(ObjectMetadata metadata) {
        // If we generated a symmetric key to encrypt the data, store it in the
        // object metadata.
        byte[] encryptedCEK = getEncryptedCEK();
        metadata.addUserMetadata(Headers.CRYPTO_KEY_V2,
                                 Base64.encodeAsString(encryptedCEK));
        // Put the cipher initialization vector (IV) into the object metadata
        byte[] iv = cipherLite.getIV();
        metadata.addUserMetadata(Headers.CRYPTO_IV, Base64.encodeAsString(iv));
        // Put the materials description into the object metadata as JSON
        metadata.addUserMetadata(Headers.MATERIALS_DESCRIPTION,
                                 kekMaterialDescAsJson());
        // The CRYPTO_CEK_ALGORITHM, CRYPTO_TAG_LENGTH and
        // CRYPTO_KEYWRAP_ALGORITHM were not available in the Encryption Only
        // (EO) implementation
        ContentCryptoScheme scheme = getContentCryptoScheme();
        metadata.addUserMetadata(Headers.CRYPTO_CEK_ALGORITHM,
                                 scheme.getCipherAlgorithm());
        int tagLen = scheme.getTagLengthInBits();
        if (tagLen > 0)
            metadata.addUserMetadata(Headers.CRYPTO_TAG_LENGTH,
                                     String.valueOf(tagLen));
        String keyWrapAlgo = getKeyWrappingAlgorithm();
        if (keyWrapAlgo != null)
            metadata.addUserMetadata(Headers.CRYPTO_KEYWRAP_ALGORITHM,
                                     keyWrapAlgo);
        return metadata;
    }
438909
def FromPublicKey(cls, public_key):
    """"""
    # Our CN will be the first 64 bits of the hash of the public key
    # in MPI format - the length of the key in 4 bytes + the key
    # prefixed with a 0. This weird format is an artifact from the way
    # M2Crypto handled this, we have to live with it for now.
    n = public_key.GetN()
    raw_n = binascii.unhexlify("%x" % n)

    mpi_format = struct.pack(">i", len(raw_n) + 1) + b"\x00" + raw_n

    digest = binascii.hexlify(hashlib.sha256(mpi_format).digest()[:8])
    return cls("C.{}".format(digest.decode("ascii")))
165294
private static String wrapSymmetricKey(KeyPair wrapperKey, SecretKey symmetricKey) throws NoSuchPaddingException,
	                                                                                          NoSuchAlgorithmException,
	                                                                                          InvalidKeyException,
	                                                                                          IllegalBlockSizeException {
		Cipher cipher = Cipher.getInstance(WRAPPER_TRANSFORMATION);
		cipher.init(Cipher.WRAP_MODE, wrapperKey.getPublic());
		byte[] decodedData = cipher.wrap(symmetricKey);
		return Base64.encodeToString(decodedData, Base64.DEFAULT);
	}
294483
def is_public(self):
        """"""
        return isinstance(self._key, Public) and not isinstance(self._key, Private)
415663
async def get_encryption_aes_key(self) -> Tuple[bytes, Dict[str, str], str]:
        
        if self.public_key is None:
            raise ValueError('Public key not provided during initialisation, cannot encrypt key encrypting key')

        random_bytes = os.urandom(32)

        ciphertext = await self._loop.run_in_executor(
            None, lambda: (self.public_key.encrypt(random_bytes, padding.PKCS1v15())))

        return random_bytes, {}, base64.b64encode(ciphertext).decode()
1203741
public static String encryptByPublicKey(String data, String publicKey) throws Exception {
		return encryptByPublicKey(data, publicKey, "RSA/ECB/PKCS1Padding");
	}
532451
public static byte[] publicKeyFromPrivate(BigInteger privKey, boolean compressed) {
        ECPoint point = publicPointFromPrivate(privKey);
        return point.getEncoded(compressed);
    }
1043800
public PublicKey
getPublicKey() throws DNSSEC.DNSSECException {
	if (publicKey != null)
		return publicKey;

	publicKey = DNSSEC.toPublicKey(this);
	return publicKey;
}
900164
def key_sign(rsakey, message, digest):
    """"""
    padding = _asymmetric.padding.PKCS1v15()
    signature = rsakey.sign(message, padding, digest)
    return signature
1119681
def get_public_key_info(self):
        
        script_parts = virtualchain.btc_script_deserialize(base64.b64decode(self.sig))
        if len(script_parts) < 2:
            return {'error': 'Signature script does not appear to encode any public keys'}

        if len(script_parts) == 2:
            # possibly p2pkh
            pubkey = script_parts[1].encode('hex')
            try:
                pubkey_object = virtualchain.ecdsalib.ecdsa_public_key(pubkey)
            except:
                return {'error': 'Could not instantiate public key {}'.format(pubkey)}

            if virtualchain.address_reencode(pubkey_object.address()) != virtualchain.address_reencode(self.address):
                return {'error': 'Public key does not match owner address {}'.format(self.address)}

            return {'status': True, 'type': 'singlesig', 'public_keys': [pubkey], 'num_sigs': 1}

        else:
            # possibly p2sh multisig.
            redeem_script = script_parts[-1]

            if virtualchain.address_reencode(virtualchain.btc_make_p2sh_address(redeem_script)) != virtualchain.address_reencode(self.address):
                return {'error': 'Multisig redeem script does not match owner address {}'.format(self.address)}

            m, pubkey_hexes = virtualchain.parse_multisig_redeemscript(redeem_script)
            for pkh in pubkey_hexes:
                try:
                    virtualchain.ecdsalib.ecdsa_public_key(pkh)
                except:
                    return {'error': 'Invalid public key string in multisig script'}

            return {'status': True, 'type': 'multisig', 'public_keys': pubkey_hexes, 'num_sigs': m}
715629
def pubkey(self, identity, ecdh=False):
        """"""
        _verify_support(identity)
        data = self.vk.to_string()
        x, y = data[:32], data[32:]
        prefix = bytearray([2 + (bytearray(y)[0] & 1)])
        return bytes(prefix) + x
462220
def public_key(self, s):
        
        s = parseable_str(s)
        for f in [self.public_pair, self.sec]:
            v = f(s)
            if v:
                return v
1253751
def certificate_object(self):
        
        if not self.certificate:
            return None
        self.certificate.seek(0)
        return crypto.parse_certificate(self.certificate.read())
362230
def export_public_key(self):
		
		if self.__public_key is None:
			raise ValueError('Unable to call this method. Public key must be set')

		return self.__public_key.public_bytes(
			encoding=serialization.Encoding.PEM,
			format=serialization.PublicFormat.SubjectPublicKeyInfo
		)
92324
static PublicKey
toPublicKey(KEYBase r) throws DNSSECException {
	int alg = r.getAlgorithm();
	try {
		switch (alg) {
		case Algorithm.RSAMD5:
		case Algorithm.RSASHA1:
		case Algorithm.RSA_NSEC3_SHA1:
		case Algorithm.RSASHA256:
		case Algorithm.RSASHA512:
			return toRSAPublicKey(r);
		case Algorithm.DSA:
		case Algorithm.DSA_NSEC3_SHA1:
			return toDSAPublicKey(r);
		default:
			throw new UnsupportedAlgorithmException(alg);
		}
	}
	catch (IOException e) {
		throw new MalformedKeyException(r);
	}
	catch (GeneralSecurityException e) {
		throw new DNSSECException(e.toString());
	}
}
839346
def public_key(self):
        

        if self._public_key is None:
            if self.algorithm == 'ec':
                key = self['private_key'].parsed
                if key['public_key']:
                    self._public_key = key['public_key'].untag()
                else:
                    self._public_key = self._compute_public_key()
            else:
                self._public_key = self._compute_public_key()

        return self._public_key