Example #1
0
// NewRsaPublicKey creates a new JWK using the given key
func NewRsaPublicKey(pk *rsa.PublicKey) (*RsaPublicKey, error) {
	k := &RsaPublicKey{
		EssentialHeader: &EssentialHeader{KeyType: "RSA"},
		N:               buffer.Buffer(pk.N.Bytes()),
		E:               buffer.FromUint(uint64(pk.E)),
	}
	return k, nil
}
Example #2
0
func NewRawKeyFromPublicKey(pubkey *rsa.PublicKey) *rawkey {
	r := &rawkey{}
	r.N = buffer.Buffer(pubkey.N.Bytes())
	r.E = buffer.FromUint(uint64(pubkey.E))
	return r
}