{"modulePath":"github.com/UnityTech/client-go","version":"v11.0.0+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package keyutil\n\nPackage keyutil contains utilities for managing public/private key pairs.\n\n## Constants\n\n```go\nconst (\n\t// ECPrivateKeyBlockType is a possible value for pem.Block.Type.\n\tECPrivateKeyBlockType = \"EC PRIVATE KEY\"\n\t// RSAPrivateKeyBlockType is a possible value for pem.Block.Type.\n\tRSAPrivateKeyBlockType = \"RSA PRIVATE KEY\"\n\t// PrivateKeyBlockType is a possible value for pem.Block.Type.\n\tPrivateKeyBlockType = \"PRIVATE KEY\"\n\t// PublicKeyBlockType is a possible value for pem.Block.Type.\n\tPublicKeyBlockType = \"PUBLIC KEY\"\n)\n```\n\n## Functions\n\n```go\nfunc LoadOrGenerateKeyFile(keyPath string) (data []byte, wasGenerated bool, err error)\n```\nLoadOrGenerateKeyFile looks for a key in the file at the given path. If it can't find one, it will generate a new key and store it there.\n\n```go\nfunc MakeEllipticPrivateKeyPEM() ([]byte, error)\n```\nMakeEllipticPrivateKeyPEM creates an ECDSA private key\n\n```go\nfunc MarshalPrivateKeyToPEM(privateKey crypto.PrivateKey) ([]byte, error)\n```\nMarshalPrivateKeyToPEM converts a known private key type of RSA or ECDSA to a PEM encoded block or returns an error.\n\n```go\nfunc ParsePrivateKeyPEM(keyData []byte) (interface{}, error)\n```\nParsePrivateKeyPEM returns a private key parsed from a PEM block in the supplied data. Recognizes PEM blocks for \"EC PRIVATE KEY\", \"RSA PRIVATE KEY\", or \"PRIVATE KEY\"\n\n```go\nfunc ParsePublicKeysPEM(keyData []byte) ([]interface{}, error)\n```\nParsePublicKeysPEM is a helper function for reading an array of rsa.PublicKey or ecdsa.PublicKey from a PEM-encoded byte array. Reads public keys from both public and private key files.\n\n```go\nfunc PrivateKeyFromFile(file string) (interface{}, error)\n```\nPrivateKeyFromFile returns the private key in rsa.PrivateKey or ecdsa.PrivateKey format from a given PEM-encoded file. Returns an error if the file could not be read or if the private key could not be parsed.\n\n```go\nfunc PublicKeysFromFile(file string) ([]interface{}, error)\n```\nPublicKeysFromFile returns the public keys in rsa.PublicKey or ecdsa.PublicKey format from a given PEM-encoded file. Reads public keys from both public and private key files.\n\n```go\nfunc WriteKey(keyPath string, data []byte) error\n```\nWriteKey writes the pem-encoded key data to keyPath. The key file will be created with file mode 0600. If the key file already exists, it will be overwritten. The parent directory of the keyPath will be created as needed with file mode 0755.\n\n","path":"github.com/UnityTech/client-go/util/keyutil","name":"keyutil","synopsis":"Package keyutil contains utilities for managing public/private key pairs.","isRedistributable":true}
