-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring working with names, finishing rebranding
- Loading branch information
Showing
10 changed files
with
98 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,17 @@ | ||
package oxicrypt | ||
|
||
import "errors" | ||
|
||
// Add your cipher implementations in factory below | ||
|
||
// GetOxiCipher - ciphers factory, get the object here | ||
func GetOxiCipher(cipherId string) (OxiCipher, error) { | ||
switch cipherId { | ||
case cCryptIDAES25601: | ||
return new(cipherAES256), nil | ||
case cNoneId: | ||
return new(cipherNONE), nil | ||
default: | ||
return nil, errors.New(OXICRPT003cipherNotFound) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,26 @@ | ||
package oxicrypt | ||
|
||
// AES 256 | ||
|
||
const AES256Id = cCryptIDAES25601 | ||
const AES256Text = cAES256TextDescription | ||
|
||
// No encryption | ||
|
||
const NoneId = cNoneId | ||
const NoneText = cNoneDescription | ||
|
||
type CipherInfo struct { | ||
ID string | ||
Description string | ||
} | ||
|
||
func GetCiphers() (ci []CipherInfo) { | ||
|
||
aes256 := CipherInfo{AES256Id, AES256Text} | ||
ci = append(ci, aes256) | ||
|
||
none := CipherInfo{NoneId, NoneText} | ||
ci = append(ci, none) | ||
return ci | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
package oxicrypt | ||
|
||
// Rules for errors definition | ||
// Example BSENCRPT00001: Password is not set | ||
// Example OXICRPT001: Password is not set | ||
// | Symbols | Possible values | Meaning | ||
// | 1 - 2 | BS | should be always BS to identify that the error is from BykovStorage | ||
// | 3 - 8 | Package ID | ENCRPT if you change this package "bsencryption" | ||
// | 9 - 12 | Digital number | Number of the error | ||
// | 13 - 14 | ": "" | Means that error id is finished, next will be desription | ||
// it is possible to put whatewer you like, I recommend to put there human readable error description in English | ||
// | 1 - 3 | OXI | should be always OXI to identify that the error is from OXI package | ||
// | 4 - 7 | Package ID | CRPT if you change this package "oxicrypt" | ||
// | 8 - 10 | Digital number | Number of the error | ||
// | 11 - 14 | ": "" | Means that error id is finished, next will be | ||
// | human-readable error description | ||
// it is possible to put whatever you like, | ||
// I recommend to put there human-readable error description in English | ||
|
||
// BSENCRPT0001EncKeyIsNotSet - BSENCRPT0001: Password is not set, encryption/decryption is not possible | ||
const BSENCRPT0001EncKeyIsNotSet = "BSENCRPT0001: Encryption key is not created, encryption/decryption is not possible" | ||
// OXICRPT001encKeyIsNotSet - OXICRPT001: Password is not set, encryption/decryption is not possible | ||
const OXICRPT001encKeyIsNotSet = "OXICRPT001: Encryption key is not created, encryption/decryption is not possible" | ||
|
||
// BSENCRPT0002WrongKeyLength - BSENCRPT0002: key length is wrong | ||
const BSENCRPT0002WrongKeyLength = "BSENCRPT0002: key length is wrong" | ||
// OXICRPT002wrongKeyLength - OXICRPT002: key length is wrong | ||
const OXICRPT002wrongKeyLength = "OXICRPT002: key length is wrong" | ||
|
||
// OXICRPT003cipherNotFound - OXICRPT003: cipher is not found | ||
const OXICRPT003cipherNotFound = "OXICRPT003: cipher is not found" | ||
|
||
const cSaltLength = 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,2 @@ | ||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 h1:/ZScEX8SfEmUGRHs0gxpqteO5nfNW6axyZbBdw9A12g= | ||
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= | ||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= | ||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||
golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= | ||
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,58 @@ | ||
package oxicrypt | ||
|
||
// No encryption consts | ||
const cryptIDNONE = "7LD92APW" | ||
const humanCryptNone = "NONE" | ||
const cNoneId = "7LD92APW" | ||
const cNoneDescription = "NONE" | ||
|
||
type cypherNONE struct { | ||
type cipherNONE struct { | ||
passwordKey []byte | ||
} | ||
|
||
func (cypher *cypherNONE) CleanAndInit() { | ||
func (cipher *cipherNONE) CleanAndInit() { | ||
} | ||
|
||
func (cypher *cypherNONE) GetCryptID() string { | ||
return cryptIDNONE | ||
func (cipher *cipherNONE) GetCryptID() string { | ||
return cNoneId | ||
} | ||
|
||
func (cypher *cypherNONE) GetCipherName() string { | ||
return humanCryptNone | ||
func (cipher *cipherNONE) GetCipherName() string { | ||
return cNoneDescription | ||
} | ||
|
||
func (cypher *cypherNONE) SetPassword(_ string) error { | ||
func (cipher *cipherNONE) SetPassword(_ string) error { | ||
return nil | ||
} | ||
|
||
func (cypher *cypherNONE) SetPasswordKey(passKey []byte) error { | ||
cypher.passwordKey = passKey | ||
func (cipher *cipherNONE) SetPasswordKey(passKey []byte) error { | ||
cipher.passwordKey = passKey | ||
return nil | ||
} | ||
func (cypher *cypherNONE) IsPasswordSet() bool { | ||
func (cipher *cipherNONE) IsPasswordSet() bool { | ||
return true | ||
} | ||
|
||
func (cypher *cypherNONE) GetPasswordKey() []byte { | ||
return cypher.passwordKey | ||
func (cipher *cipherNONE) GetPasswordKey() []byte { | ||
return cipher.passwordKey | ||
} | ||
|
||
func (cypher *cypherNONE) EncryptBLOB(inStr string) ([]byte, error) { | ||
func (cipher *cipherNONE) EncryptBLOB(inStr string) ([]byte, error) { | ||
return []byte(inStr), nil | ||
} | ||
|
||
func (cypher *cypherNONE) DecryptBLOB(inData []byte) (string, error) { | ||
func (cipher *cipherNONE) DecryptBLOB(inData []byte) (string, error) { | ||
return string(inData[:]), nil | ||
} | ||
|
||
func (cypher *cypherNONE) EncryptBIN(inData []byte) ([]byte, error) { | ||
func (cipher *cipherNONE) EncryptBIN(inData []byte) ([]byte, error) { | ||
return inData, nil | ||
} | ||
func (cypher *cypherNONE) DecryptBIN(inData []byte) ([]byte, error) { | ||
func (cipher *cipherNONE) DecryptBIN(inData []byte) ([]byte, error) { | ||
return inData, nil | ||
} | ||
|
||
func (cypher *cypherNONE) Encrypt(text string) (string, error) { | ||
func (cipher *cipherNONE) Encrypt(text string) (string, error) { | ||
return text, nil | ||
} | ||
|
||
func (cypher *cypherNONE) Decrypt(encryptedText string) (string, error) { | ||
func (cipher *cipherNONE) Decrypt(encryptedText string) (string, error) { | ||
return encryptedText, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters