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.
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 ¶
- Variables
- func BytesToHermesBuffer(data []byte) *C.mid_hermes_ll_buffer_t
- func CopyHermesUser(hermesUser *C.mid_hermes_ll_user_t) (*C.mid_hermes_ll_user_t, error)
- func HermesBufferToBytes(hermesBuffer *C.mid_hermes_ll_buffer_t) []byte
- func PackBlock(block *Block) ([]byte, error)
- func UnpackBlock(data []byte) ([]byte, []byte, []byte, error)
- type Block
- func NewBlockFromData(user *User, id, rawData, meta []byte) (*Block, error)
- func NewBlockFromDataWithTokens(user *User, id, rawData, meta []byte, readToken, writeToken *Token) (*Block, error)
- func NewBlockFromEncryptedData(user *User, id, encryptedData, meta []byte, readToken, writeToken *Token) (*Block, error)
- func (block *Block) GetData() []byte
- func (block *Block) GetEncryptedData() []byte
- func (block *Block) GetEncryptedDataLength() int
- func (block *Block) GetId() []byte
- func (block *Block) GetMac() []byte
- func (block *Block) GetMacLength() int
- func (block *Block) GetMeta() []byte
- func (block *Block) GetOldMac() []byte
- func (block *Block) GetReadToken() (*Token, error)
- func (block *Block) GetUser() (*User, error)
- func (block *Block) GetWriteToken() (*Token, error)
- func (block *Block) HasWriteToken() bool
- func (block *Block) SetOldMac(oldMac []byte)
- func (block *Block) Update(data, meta []byte) error
- type Buffer
- type Token
- type User
Constants ¶
This section is empty.
Variables ¶
var ErrHermesBlockCreation = errors.New("hermes-core return null on block creation")
var ErrHermesBlockUpdate = errors.New("hermes-core return null on block update")
var ErrHermesBufferCreationError = errors.New("hermes-core return null on buffer create operation")
var ErrHermesTokenCreateError = errors.New("hermes-core return null on token creation")
var ErrHermesTokenGenerationError = errors.New("hermes-core return null on token generate operation")
var ErrUserCopy = errors.New("can't make user copy")
var ErrUserCreation = errors.New("id or private key is empty")
Functions ¶
func BytesToHermesBuffer ¶
func BytesToHermesBuffer(data []byte) *C.mid_hermes_ll_buffer_t
BytesToHermesBuffer return copy of data wrapped into *C.mid_hermes_ll_buffer_t
func CopyHermesUser ¶
func CopyHermesUser(hermesUser *C.mid_hermes_ll_user_t) (*C.mid_hermes_ll_user_t, error)
func HermesBufferToBytes ¶
func HermesBufferToBytes(hermesBuffer *C.mid_hermes_ll_buffer_t) []byte
HermesBufferToBytes return copy of hermes buffer as byte slice
Types ¶
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block wrap C struct of hermes block
func NewBlockFromData ¶
NewBlockFromData return new Block that generate new tokens, encrypt rawData and contain rawData, encryptedData and new tokens
func NewBlockFromDataWithTokens ¶
func NewBlockFromDataWithTokens(user *User, id, rawData, meta []byte, readToken, writeToken *Token) (*Block, error)
NewBlockFromDataWithTokens return block and encrypt data using readToken and writeToken
func NewBlockFromEncryptedData ¶
func NewBlockFromEncryptedData(user *User, id, encryptedData, meta []byte, readToken, writeToken *Token) (*Block, error)
NewBlockFromEncryptedData return block and decrypt encrypted data using readToken and writeToken
func (*Block) GetEncryptedData ¶
GetEncryptedData return encrypted data of block
func (*Block) GetEncryptedDataLength ¶
GetEncryptedDataLength return length of decrypted data
func (*Block) GetReadToken ¶
GetReadToken return read token that was generated after creation new block or after initialization with read token
func (*Block) GetWriteToken ¶
GetWriteToken return write token that was generated after creation new block or after initialization with write token
func (*Block) HasWriteToken ¶
HasWriteToken return true if block has related write token
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer wrap mid_hermes_ll_buffer_t C struct
func NewFromHermesBuffer ¶
func NewFromHermesBuffer(hermesBuffer *C.mid_hermes_ll_buffer_t) (*Buffer, error)
NewFromHermesBuffer return new *Block with hermesBuffer copy
func NewHermesBuffer ¶
NewHermesBuffer return new *Buffer that wraps data
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
Token wrap mid_hermes_ll_token_t C struct
func NewTokenFromEncryptedBytes ¶
NewTokenFromEncryptedBytes create new hermes token object with encrypted token tokenData
func NewTokenFromHermesToken ¶
func NewTokenFromHermesToken(hermesToken *C.mid_hermes_ll_token_t) (*Token, error)
NewTokenFromHermesToken return new Token that use copy of hermesToken data
func (*Token) GetEncryptedData ¶
GetEncryptedData return encrypted token as is
func (*Token) GetHermesToken ¶
func (token *Token) GetHermesToken() (*C.mid_hermes_ll_token_t, error)
GetHermesToken return pointer to wrapped copy of mid_hermes_ll_token_t
type User ¶
type User struct {
// contains filtered or unexported fields
}
User wraps mid_hermes_ll_user_t C struct
func NewUser ¶
NewUser return new User object. privateKey can be empty []byte or nil but publicKey not hermes uses themis key generation functions so private/public keys should be generates via github.com/cossacklabs/themis/gothemis/keys.NewBlock function
func NewUserFromHermesUser ¶
func NewUserFromHermesUser(hermesUser *C.mid_hermes_ll_user_t) (*User, error)
NewUserFromHermesUser return new *User that wraps copy of hermesUser
func (*User) Copy ¶
Copy return copy of user without runtime.finalizer and copied hermesUser object should be free manually or by C code
func (*User) GetHermesUser ¶
func (user *User) GetHermesUser() (*C.mid_hermes_ll_user_t, error)
GetHermesUser return copy of wrapped mid_hermes_ll_user_t struct