// SetPublicKeyPEM is a convenience method to set the PublicKey property
// used for checking a completed update's signature by parsing a
// Public Key formatted as PEM data.
328936
func (o *Options) SetPublicKeyPEM(pembytes []byte) error {
	block, _ := pem.Decode(pembytes)
	if block == nil {
		return errors.New("couldn't parse PEM data")
	}

	pub, err := x509.ParsePKIXPublicKey(block.Bytes)
	if err != nil {
		return err
	}
	o.PublicKey = pub
	return nil
}
1308173
func (s *CreateDevEndpointInput) SetPublicKey(v string) *CreateDevEndpointInput {
	s.PublicKey = &v
	return s
}
1114863
func (soc *Socket) SetCurvePublickey(key string) error {
	return soc.setString(C.ZMQ_CURVE_PUBLICKEY, key)
}
900136
func (s *ListPublicKeysOutput) SetPublicKeyList(v []*PublicKey) *ListPublicKeysOutput {
	s.PublicKeyList = v
	return s
}
242991
func (s *DescribeUserProfileOutput) SetSshPublicKey(v string) *DescribeUserProfileOutput {
	s.SshPublicKey = &v
	return s
}
685086
func (s *Cluster) SetClusterPublicKey(v string) *Cluster {
	s.ClusterPublicKey = &v
	return s
}
933749
func (s *DeleteSshPublicKeyInput) SetSshPublicKeyId(v string) *DeleteSshPublicKeyInput {
	s.SshPublicKeyId = &v
	return s
}
807536
func generatePEM(opts CertOptions) ([]byte, []byte, error) {
	certBytes, privateKey, err := generate(opts)
	if err != nil {
		return nil, nil, err
	}
	certpem := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: certBytes})
	keypem := pem.EncodeToMemory(pemBlockForKey(privateKey))
	return certpem, keypem, nil
}
707143
func (s *UpdateUserProfileOutput) SetSshPublicKey(v string) *UpdateUserProfileOutput {
	s.SshPublicKey = &v
	return s
}
540158
func UpdatePublicKey(key *PublicKey) error {
	_, err := x.Id(key.ID).AllCols().Update(key)
	return err
}
882980
func (s *CreateKeyPairOutput) SetPublicKeyBase64(v string) *CreateKeyPairOutput {
	s.PublicKeyBase64 = &v
	return s
}
1362073
func ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error) {
	var err error

	// Parse PEM block
	var block *pem.Block
	if block, _ = pem.Decode(key); block == nil {
		return nil, ErrKeyMustBePEMEncoded
	}

	// Parse the key
	var parsedKey interface{}
	if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil {
		if cert, err := x509.ParseCertificate(block.Bytes); err == nil {
			parsedKey = cert.PublicKey
		} else {
			return nil, err
		}
	}

	var pkey *rsa.PublicKey
	var ok bool
	if pkey, ok = parsedKey.(*rsa.PublicKey); !ok {
		return nil, ErrNotRSAPublicKey
	}

	return pkey, nil
}
641153
func (s *RegisterUsageInput) SetPublicKeyVersion(v int64) *RegisterUsageInput {
	s.PublicKeyVersion = &v
	return s
}
819345
func (s *CreateUserProfileInput) SetSshPublicKey(v string) *CreateUserProfileInput {
	s.SshPublicKey = &v
	return s
}
91853
func (s *RegisterInstanceInput) SetRsaPublicKey(v string) *RegisterInstanceInput {
	s.RsaPublicKey = &v
	return s
}
369423
func (s *CreateUserInput) SetSshPublicKeyBody(v string) *CreateUserInput {
	s.SshPublicKeyBody = &v
	return s
}
457878
func (s *ImportKeyPairInput) SetPublicKeyBase64(v string) *ImportKeyPairInput {
	s.PublicKeyBase64 = &v
	return s
}