Documentation ¶
Index ¶
- Constants
- Variables
- func AESDecrypt(encodedData, key []byte) ([]byte, error)
- func AESEncrypt(plainText, key []byte) ([]byte, error)
- func CheckDataForFieldQuery(fileName string, data *gjson.Result) (bool, error)
- func CheckPasswordSalt(hashedPassword, password string) bool
- func CreateSecurityKey(keyLength int) (string, error)
- func GenSecKey(fileName string, data *gjson.Result) (string, error)
- func GenSecKeyBytes(fileName string, data *gjson.Result) ([]byte, error)
- func GetHash(plaintext string) (string, error)
- func GetHashAndSalt(plaintext, salt string) (string, error)
- func PaddingDataUsingpkcs7(buf []byte, size int) ([]byte, error)
- func SaltPassword(password string) (string, error)
- func SetIV(initializationVector string)
- func SetSecurityConfig(secKey []byte, initializationVector string)
- func SetSecurityKey(secKey []byte)
- func SetSecurityKeyGeneratorFunc(genratorFunc SecurityKeyGeneratorFunc)
- func UnpaddingDataUsingpkcs7(padded []byte, size int) ([]byte, error)
- type FDBSecOptions
- type FDBSecParams
- type SecurityKeyGeneratorFunc
Constants ¶
const ( SEC_ENCKey = "encKey" SEC_UserKey = "userKey" SEC_FieldQuery = "fieldQuery" SEC_SECURITY = "security" )
const ( // SharedPrefix prefix represents the file is sharable i.e encryption key does not include (fdbSec.fieldQuery) EmptySTR = "" )
Variables ¶
var IV = ""
IV set IV for dev mode
Functions ¶
func AESDecrypt ¶
AESDecrypt Decrypts given cipher text
func AESEncrypt ¶
AESEncrypt Encrypts given text
func CheckDataForFieldQuery ¶
CheckDataForFieldQuery checks for result of field query in data.
If no query is provided OR Not shared file, the result will be false, nil ¶
Else will check for query result. If result is empty, error will be thrown.
Check only if security is enabled for the database.
fileName must not be empty and data must not be nil
func CheckPasswordSalt ¶
CheckPasswordSalt - compares hashed password with its possible plaintext equivalent. Returns true on match, or an false on mismatch.
func CreateSecurityKey ¶
CreateSecurityKey generates random string of given length
func GenSecKeyBytes ¶
GenSecKey generates the security key for FDB.
If fileName has prefix "ss_" then key is generated by 1. Global encryption key (fdbSec.encKey) 2. UserDefinedKey (fdbSec.userDefinedKey) 3. fileName
else result by firing (fdbSec.fieldQuery) on data is also included in generation. If rusult is empty, expect an error.
Order for key: data.Get(fdbSec.fieldQuery).String() + fdbSec.encKey + fdbSec.userDefinedKey + fileName(only)
func GetHashAndSalt ¶
GetHashAndSalt - returns Hash Check sum of given plaintext+ salt combination
func PaddingDataUsingpkcs7 ¶
PaddingDataUsingpkcs7 - This methods is copy from https://github.com/mergermarket/go-pkcs7
func SaltPassword ¶
SaltPassword Salt using bcrypt creates saltedString of given string,it generates new saltedString each time for the same input
func SetSecurityConfig ¶
SetSecurityConfig will set security key and initializationVector
func SetSecurityKeyGeneratorFunc ¶
func SetSecurityKeyGeneratorFunc(genratorFunc SecurityKeyGeneratorFunc)
SetSecurityKeyGeneratorFunc - sets default security Key
func UnpaddingDataUsingpkcs7 ¶
UnpaddingDataUsingpkcs7 - his methods is copy from https://github.com/mergermarket/go-pkcs7
Types ¶
type FDBSecOptions ¶
type FDBSecOptions struct { EncKey string // the global encryption key used in the project. This key will be applicable in all cases. UserDefinedKey string // the user defined key in the project. This key will be applicable in all cases. FieldQuery string // query to get dynamic field. Ex. Each student data can be encrypted with studentID. Applicable only for the shared bucket. }
FDBSecOptions provide options to be set for fdb security. All fields are compulsorry. On applying options, we will get error if any field is empty. Only these options are exposed as actual
func GetFDBSecOptions ¶
func GetFDBSecOptions() FDBSecOptions
GetFDBSecOptions returns the copy of fdb options set by Apply() method.
func NewFDBOptions ¶
func NewFDBOptions() *FDBSecOptions
func (*FDBSecOptions) Apply ¶
func (fo *FDBSecOptions) Apply() error
Apply sets the internal security variable.
Returns error if options fail while validations and if Apply() is already called.
func (*FDBSecOptions) Validate ¶
func (fs *FDBSecOptions) Validate() error
Validate checks options for empty fields.
type FDBSecParams ¶
FDBSecParams provide options for the FDB security for the FDB CRUD operations.
type SecurityKeyGeneratorFunc ¶
SecurityKeyGeneratorFunc - header definition
func GetSecurityKeyGeneratorFunc ¶
func GetSecurityKeyGeneratorFunc() SecurityKeyGeneratorFunc
GetSecurityKeyGeneratorFunc - returns security Key