Documentation ¶
Overview ¶
Copyright 2016, Cossack Labs Limited
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016, Cossack Labs Limited ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2016, Cossack Labs Limited ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func CheckReadWrite(n, expectedN int, err error, errCh chan<- error) bool
- func DecryptAcrastruct(data []byte, privateKey *keys.PrivateKey, zone []byte) ([]byte, error)
- type DataDecryptor
- type Decryptor
- type ExecuteScriptCallback
- type PoisonCallback
- type PoisonCallbackStorage
- type StopCallback
Constants ¶
const ( // length of EC public key PUBLIC_KEY_LENGTH = 45 // length of 32 byte of symmetric key wrapped to smessage SMESSAGE_KEY_LENGTH = 84 KEY_BLOCK_LENGTH = PUBLIC_KEY_LENGTH + SMESSAGE_KEY_LENGTH SYMMETRIC_KEY_SIZE = 32 DATA_LENGTH_SIZE = 8 )
const (
LENGTH_SIZE = 8
)
const (
TAG_SYMBOL byte = '"'
)
var TAG_BEGIN = []byte{133, 32, 251}
Variables ¶
var ErrFakeAcraStruct = errors.New("fake acra struct")
error show that failed acra struct recognizing but data is may be valid
var ErrPoisonRecord = errors.New("poison record detected")
var TAG_BEGIN = []byte{TAG_SYMBOL, TAG_SYMBOL, TAG_SYMBOL, TAG_SYMBOL, TAG_SYMBOL, TAG_SYMBOL, TAG_SYMBOL, TAG_SYMBOL}
Functions ¶
func DecryptAcrastruct ¶
Types ¶
type DataDecryptor ¶
type DataDecryptor interface { // try match begin tag per byte MatchBeginTag(byte) bool // return true if all bytes from begin tag matched by MatchBeginTag IsMatched() bool // reset state of matching begin tag Reset() // return all matched begin tag bytes GetMatched() []byte // read, decode from db format block of data, decrypt symmetric key from // acrastruct using secure message // return decrypted data or data as is if fail // db specific ReadSymmetricKey(*keys.PrivateKey, io.Reader) ([]byte, []byte, error) // read and decrypt data or return as is if fail // db specific ReadData([]byte, []byte, io.Reader) ([]byte, error) GetTagBeginLength() int }
type Decryptor ¶
type Decryptor interface { DataDecryptor // register key store that will be used for retrieving private keys SetKeyStore(keystore.KeyStore) // return private key for current connected client for decrypting symmetric // key with secure message GetPrivateKey() (*keys.PrivateKey, error) // register storage of callbacks for detected poison records SetPoisonCallbackStorage(*PoisonCallbackStorage) // get current storage of callbacks for detected poison records GetPoisonCallbackStorage() *PoisonCallbackStorage SetZoneMatcher(*zone.ZoneIdMatcher) GetMatchedZoneId() []byte MatchZone(byte) bool IsWithZone() bool SetWithZone(bool) IsMatchedZone() bool ResetZoneMatch() IsWholeMatch() bool DecryptBlock([]byte) ([]byte, error) SkipBeginInBlock(block []byte) ([]byte, error) MatchZoneBlock([]byte) CheckPoisonRecord(reader io.Reader) (bool, error) // return tag start index and length of tag (depends on decryptor type) BeginTagIndex([]byte) (int, int) MatchZoneInBlock([]byte) }
type ExecuteScriptCallback ¶
type ExecuteScriptCallback struct {
// contains filtered or unexported fields
}
func NewExecuteScriptCallback ¶
func NewExecuteScriptCallback(path string) *ExecuteScriptCallback
func (*ExecuteScriptCallback) Call ¶
func (callback *ExecuteScriptCallback) Call() error
type PoisonCallback ¶
type PoisonCallback interface {
Call() error
}
type PoisonCallbackStorage ¶
type PoisonCallbackStorage struct {
// contains filtered or unexported fields
}
func NewPoisonCallbackStorage ¶
func NewPoisonCallbackStorage() *PoisonCallbackStorage
func (*PoisonCallbackStorage) AddCallback ¶
func (storage *PoisonCallbackStorage) AddCallback(callback PoisonCallback)
func (*PoisonCallbackStorage) Call ¶
func (storage *PoisonCallbackStorage) Call() error
func (*PoisonCallbackStorage) HasCallbacks ¶
func (storage *PoisonCallbackStorage) HasCallbacks() bool
type StopCallback ¶
type StopCallback struct{}
func (*StopCallback) Call ¶
func (*StopCallback) Call() error