func (parsed rawHeader) getString(k HeaderKey) string {
	v, ok := parsed[k]
	if !ok {
		return ""
	}
	var s string
	err := json.Unmarshal(*v, &s)
	if err != nil {
		return ""
	}
	return s
}
getString gets a string from the raw JSON, defaulting to "".
package jose
import (
	"crypto/elliptic"
	"crypto/x509"
	"encoding/base64"
	"errors"
	"fmt"
	"gopkg.in/square/go-jose.v2/json"
)
type KeyAlgorithm string
type SignatureAlgorithm string
type ContentEncryption string
type CompressionAlgorithm string
type ContentType string
var (
	ErrCryptoFailure = errors.New("square/go-jose: error in cryptographic primitive")
	ErrUnsupportedAlgorithm = errors.New("square/go-jose: unknown/unsupported algorithm")
	ErrUnsupportedKeyType = errors.New("square/go-jose: unsupported key type/format")
	ErrNotSupported = errors.New("square/go-jose: compact serialization not supported for object")
	ErrUnprotectedNonce = errors.New("square/go-jose: Nonce parameter included in unprotected header")
)
const (
	ED25519            = KeyAlgorithm("ED25519")
	RSA1_5             = KeyAlgorithm("RSA1_5")              
	RSA_OAEP           = KeyAlgorithm("RSA-OAEP")            
	RSA_OAEP_256       = KeyAlgorithm("RSA-OAEP-256")        
	A128KW             = KeyAlgorithm("A128KW")              
	A192KW             = KeyAlgorithm("A192KW")              
	A256KW             = KeyAlgorithm("A256KW")              
	DIRECT             = KeyAlgorithm("dir")                 
	ECDH_ES            = KeyAlgorithm("ECDH-ES")             
	ECDH_ES_A128KW     = KeyAlgorithm("ECDH-ES+A128KW")      
	ECDH_ES_A192KW     = KeyAlgorithm("ECDH-ES+A192KW")      
	ECDH_ES_A256KW     = KeyAlgorithm("ECDH-ES+A256KW")      
	A128GCMKW          = KeyAlgorithm("A128GCMKW")           
	A192GCMKW          = KeyAlgorithm("A192GCMKW")           
	A256GCMKW          = KeyAlgorithm("A256GCMKW")           
	PBES2_HS256_A128KW = KeyAlgorithm("PBES2-HS256+A128KW")  
	PBES2_HS384_A192KW = KeyAlgorithm("PBES2-HS384+A192KW")  
	PBES2_HS512_A256KW = KeyAlgorithm("PBES2-HS512+A256KW")  
)
const (
	EdDSA = SignatureAlgorithm("EdDSA")
	HS256 = SignatureAlgorithm("HS256")  
	HS384 = SignatureAlgorithm("HS384")  
	HS512 = SignatureAlgorithm("HS512")  
	RS256 = SignatureAlgorithm("RS256")  
	RS384 = SignatureAlgorithm("RS384")  
	RS512 = SignatureAlgorithm("RS512")  
	ES256 = SignatureAlgorithm("ES256")  
	ES384 = SignatureAlgorithm("ES384")  
	ES512 = SignatureAlgorithm("ES512")  
	PS256 = SignatureAlgorithm("PS256")  
	PS384 = SignatureAlgorithm("PS384")  
	PS512 = SignatureAlgorithm("PS512")  
)
const (
	A128CBC_HS256 = ContentEncryption("A128CBC-HS256")  
	A192CBC_HS384 = ContentEncryption("A192CBC-HS384")  
	A256CBC_HS512 = ContentEncryption("A256CBC-HS512")  
	A128GCM       = ContentEncryption("A128GCM")        
	A192GCM       = ContentEncryption("A192GCM")        
	A256GCM       = ContentEncryption("A256GCM")        
)
const (
	NONE    = CompressionAlgorithm("")     
	DEFLATE = CompressionAlgorithm("DEF")  
)
type HeaderKey string
const (
	HeaderType        HeaderKey = "typ"  
	HeaderContentType           = "cty"  
	headerAlgorithm   = "alg"   
	headerEncryption  = "enc"   
	headerCompression = "zip"   
	headerCritical    = "crit"  
	headerAPU = "apu"  
	headerAPV = "apv"  
	headerEPK = "epk"  
	headerIV  = "iv"   
	headerTag = "tag"  
	headerX5c = "x5c"  
	headerJWK   = "jwk"    
	headerKeyID = "kid"    
	headerNonce = "nonce"  
)
type rawHeader map[HeaderKey]*json.RawMessage
type Header struct {
	KeyID      string
	JSONWebKey *JSONWebKey
	Algorithm  string
	Nonce      string
	certificates []*x509.Certificate
	ExtraHeaders map[HeaderKey]interface{}
}
func (h Header) Certificates(opts x509.VerifyOptions) ([][]*x509.Certificate, error) {
	if len(h.certificates) == 0 {
		return nil, errors.New("square/go-jose: no x5c header present in message")
	}
	leaf := h.certificates[0]
	if opts.Intermediates == nil {
		opts.Intermediates = x509.NewCertPool()
		for _, intermediate := range h.certificates[1:] {
			opts.Intermediates.AddCert(intermediate)
		}
	}
	return leaf.Verify(opts)
}
func (parsed rawHeader) set(k HeaderKey, v interface{}) error {
	b, err := json.Marshal(v)
	if err != nil {
		return err
	}
	parsed[k] = makeRawMessage(b)
	return nil
}