Documentation ¶
Overview ¶
license: https://mit-license.org * ============================================================================== * The MIT License (MIT) * * Copyright (c) 2020 Albert Moky * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * ==============================================================================
license: https://mit-license.org * ============================================================================== * The MIT License (MIT) * * Copyright (c) 2021 Albert Moky * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * ==============================================================================
license: https://mit-license.org * ============================================================================== * The MIT License (MIT) * * Copyright (c) 2021 Albert Moky * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * ==============================================================================
license: https://mit-license.org * ============================================================================== * The MIT License (MIT) * * Copyright (c) 2020 Albert Moky * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * ==============================================================================
license: https://mit-license.org * ============================================================================== * The MIT License (MIT) * * Copyright (c) 2021 Albert Moky * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * ==============================================================================
license: https://mit-license.org * ============================================================================== * The MIT License (MIT) * * Copyright (c) 2020 Albert Moky * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * ==============================================================================
Index ¶
- Variables
- func GetPlainKey() SymmetricKey
- func MarshalPKCS8PrivateKey(key *rsa.PrivateKey) []byte
- func NewAESKey(dict map[string]interface{}) SymmetricKey
- func NewECCPrivateKey(dict map[string]interface{}) PrivateKey
- func NewECCPublicKey(dict map[string]interface{}) PublicKey
- func NewPlainKey() SymmetricKey
- func NewPrivateKeyFactory(g PrivateKeyGenerator, p PrivateKeyParser) PrivateKeyFactory
- func NewPublicKeyFactory(p PublicKeyParser) PublicKeyFactory
- func NewRSAPrivateKey(dict map[string]interface{}) PrivateKey
- func NewRSAPublicKey(dict map[string]interface{}) PublicKey
- func NewSymmetricKeyFactory(g SymmetricKeyGenerator, p SymmetricKeyParser) SymmetricKeyFactory
- func PKCS5Padding(src []byte, blockSize uint) []byte
- func PKCS5UnPadding(src []byte) []byte
- func RegisterPrivateKeyFactories()
- func RegisterPublicKeyFactories()
- func RegisterSymmetricKeyFactories()
- type AESKey
- type BaseKey
- type BasePrivateKey
- type BasePublicKey
- type BaseSymmetricKey
- type ECCPrivateKey
- type ECCPublicKey
- type GeneralPrivateKeyFactory
- type GeneralPublicKeyFactory
- type GeneralSymmetricKeyFactory
- type PlainKey
- type PrivateKeyGenerator
- type PrivateKeyParser
- type PublicKeyParser
- type RSAPrivateKey
- func (key *RSAPrivateKey) Data() []byte
- func (key *RSAPrivateKey) Decrypt(ciphertext []byte) []byte
- func (key *RSAPrivateKey) Init(dict map[string]interface{}) PrivateKey
- func (key *RSAPrivateKey) Match(pKey EncryptKey) bool
- func (key *RSAPrivateKey) PublicKey() PublicKey
- func (key *RSAPrivateKey) Sign(data []byte) []byte
- type RSAPublicKey
- type SymmetricKeyGenerator
- type SymmetricKeyParser
Constants ¶
This section is empty.
Variables ¶
var PLAIN = "PLAIN"
*
- Symmetric key for broadcast message,
- which will do nothing when en/decoding message data
Functions ¶
func GetPlainKey ¶
func GetPlainKey() SymmetricKey
func MarshalPKCS8PrivateKey ¶
func MarshalPKCS8PrivateKey(key *rsa.PrivateKey) []byte
func NewECCPrivateKey ¶
func NewECCPrivateKey(dict map[string]interface{}) PrivateKey
func NewECCPublicKey ¶
func NewECCPublicKey(dict map[string]interface{}) PublicKey
func NewPlainKey ¶
func NewPlainKey() SymmetricKey
func NewPrivateKeyFactory ¶
func NewPrivateKeyFactory(g PrivateKeyGenerator, p PrivateKeyParser) PrivateKeyFactory
func NewPublicKeyFactory ¶
func NewPublicKeyFactory(p PublicKeyParser) PublicKeyFactory
func NewRSAPrivateKey ¶
func NewRSAPrivateKey(dict map[string]interface{}) PrivateKey
func NewRSAPublicKey ¶
func NewRSAPublicKey(dict map[string]interface{}) PublicKey
func NewSymmetricKeyFactory ¶
func NewSymmetricKeyFactory(g SymmetricKeyGenerator, p SymmetricKeyParser) SymmetricKeyFactory
func PKCS5Padding ¶
func PKCS5UnPadding ¶
func RegisterPrivateKeyFactories ¶
func RegisterPrivateKeyFactories()
func RegisterPublicKeyFactories ¶
func RegisterPublicKeyFactories()
func RegisterSymmetricKeyFactories ¶
func RegisterSymmetricKeyFactories()
Types ¶
type AESKey ¶
type AESKey struct { BaseSymmetricKey // contains filtered or unexported fields }
*
- AES Key *
- keyInfo format: {
- algorithm: "AES",
- keySize : 32, // optional
- data : "{BASE64_ENCODE}}" // password data
- iv : "{BASE64_ENCODE}", // initialization vector
- }
type BasePrivateKey ¶
type BasePrivateKey struct {
BaseKey
}
*
- Asymmetric Private Key
- ~~~~~~~~~~~~~~~~~~~~~~
type BasePublicKey ¶
type BasePublicKey struct {
BaseKey
}
*
- Asymmetric Public Key
- ~~~~~~~~~~~~~~~~~~~~~
func (*BasePublicKey) Match ¶
func (key *BasePublicKey) Match(sKey SignKey) bool
type BaseSymmetricKey ¶
type BaseSymmetricKey struct {
BaseKey
}
*
- Symmetric Key
- ~~~~~~~~~~~~~
func (*BaseSymmetricKey) Decrypt ¶
func (key *BaseSymmetricKey) Decrypt(_ []byte) []byte
func (*BaseSymmetricKey) Match ¶
func (key *BaseSymmetricKey) Match(pKey EncryptKey) bool
type ECCPrivateKey ¶
type ECCPrivateKey struct { BasePrivateKey // contains filtered or unexported fields }
*
- ECC Private Key *
- keyInfo format: {
- algorithm : "ECC",
- data : "..." // base64_encode()
- }
func (*ECCPrivateKey) Data ¶
func (key *ECCPrivateKey) Data() []byte
func (*ECCPrivateKey) Init ¶
func (key *ECCPrivateKey) Init(dict map[string]interface{}) PrivateKey
func (*ECCPrivateKey) PublicKey ¶
func (key *ECCPrivateKey) PublicKey() PublicKey
func (*ECCPrivateKey) Sign ¶
func (key *ECCPrivateKey) Sign(data []byte) []byte
type ECCPublicKey ¶
type ECCPublicKey struct { BasePublicKey // contains filtered or unexported fields }
*
- ECC Public Key *
- keyInfo format: {
- algorithm : "ECC",
- data : "..." // base64_encode()
- }
func (*ECCPublicKey) Data ¶
func (key *ECCPublicKey) Data() []byte
func (*ECCPublicKey) Init ¶
func (key *ECCPublicKey) Init(dict map[string]interface{}) PublicKey
type GeneralPrivateKeyFactory ¶
type GeneralPrivateKeyFactory struct {
// contains filtered or unexported fields
}
private key factory
func (*GeneralPrivateKeyFactory) GeneratePrivateKey ¶
func (factory *GeneralPrivateKeyFactory) GeneratePrivateKey() PrivateKey
func (*GeneralPrivateKeyFactory) Init ¶
func (factory *GeneralPrivateKeyFactory) Init(g PrivateKeyGenerator, p PrivateKeyParser) PrivateKeyFactory
func (*GeneralPrivateKeyFactory) ParsePrivateKey ¶
func (factory *GeneralPrivateKeyFactory) ParsePrivateKey(key map[string]interface{}) PrivateKey
type GeneralPublicKeyFactory ¶
type GeneralPublicKeyFactory struct {
// contains filtered or unexported fields
}
public key factory
func (*GeneralPublicKeyFactory) Init ¶
func (factory *GeneralPublicKeyFactory) Init(p PublicKeyParser) PublicKeyFactory
func (*GeneralPublicKeyFactory) ParsePublicKey ¶
func (factory *GeneralPublicKeyFactory) ParsePublicKey(key map[string]interface{}) PublicKey
type GeneralSymmetricKeyFactory ¶
type GeneralSymmetricKeyFactory struct {
// contains filtered or unexported fields
}
symmetric key factory
func (*GeneralSymmetricKeyFactory) GenerateSymmetricKey ¶
func (factory *GeneralSymmetricKeyFactory) GenerateSymmetricKey() SymmetricKey
func (*GeneralSymmetricKeyFactory) Init ¶
func (factory *GeneralSymmetricKeyFactory) Init(g SymmetricKeyGenerator, p SymmetricKeyParser) SymmetricKeyFactory
func (*GeneralSymmetricKeyFactory) ParseSymmetricKey ¶
func (factory *GeneralSymmetricKeyFactory) ParseSymmetricKey(key map[string]interface{}) SymmetricKey
type PlainKey ¶
type PlainKey struct { BaseSymmetricKey // contains filtered or unexported fields }
type PrivateKeyParser ¶
type PrivateKeyParser func(map[string]interface{}) PrivateKey
type PublicKeyParser ¶
type PublicKeyParser func(map[string]interface{}) PublicKey
type RSAPrivateKey ¶
type RSAPrivateKey struct { BasePrivateKey // contains filtered or unexported fields }
*
- RSA Private Key *
- keyInfo format: {
- algorithm : "RSA",
- data : "..." // base64_encode()
- }
func (*RSAPrivateKey) Data ¶
func (key *RSAPrivateKey) Data() []byte
func (*RSAPrivateKey) Decrypt ¶
func (key *RSAPrivateKey) Decrypt(ciphertext []byte) []byte
func (*RSAPrivateKey) Init ¶
func (key *RSAPrivateKey) Init(dict map[string]interface{}) PrivateKey
func (*RSAPrivateKey) Match ¶
func (key *RSAPrivateKey) Match(pKey EncryptKey) bool
func (*RSAPrivateKey) PublicKey ¶
func (key *RSAPrivateKey) PublicKey() PublicKey
func (*RSAPrivateKey) Sign ¶
func (key *RSAPrivateKey) Sign(data []byte) []byte
type RSAPublicKey ¶
type RSAPublicKey struct { BasePublicKey // contains filtered or unexported fields }
*
- RSA Public Key *
- keyInfo format: {
- algorithm: "RSA",
- data: "..." // base64
- }
func (*RSAPublicKey) Data ¶
func (key *RSAPublicKey) Data() []byte
func (*RSAPublicKey) Encrypt ¶
func (key *RSAPublicKey) Encrypt(plaintext []byte) []byte
func (*RSAPublicKey) Init ¶
func (key *RSAPublicKey) Init(dict map[string]interface{}) PublicKey
type SymmetricKeyParser ¶
type SymmetricKeyParser func(map[string]interface{}) SymmetricKey
Directories ¶
Path | Synopsis |
---|---|
license: https://mit-license.org * ============================================================================== * The MIT License (MIT) * * Copyright (c) 2021 Albert Moky * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software.
|
license: https://mit-license.org * ============================================================================== * The MIT License (MIT) * * Copyright (c) 2021 Albert Moky * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. |