core

package
v0.0.0-...-7f4cb87 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2021 License: AGPL-3.0 Imports: 7 Imported by: 0

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.

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.

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.

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.

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

This section is empty.

Variables

View Source
var ErrHermesBlockCreation = errors.New("hermes-core return null on block creation")
View Source
var ErrHermesBlockUpdate = errors.New("hermes-core return null on block update")
View Source
var ErrHermesBufferCreationError = errors.New("hermes-core return null on buffer create operation")
View Source
var ErrHermesTokenCreateError = errors.New("hermes-core return null on token creation")
View Source
var ErrHermesTokenGenerationError = errors.New("hermes-core return null on token generate operation")
View Source
var ErrUserCopy = errors.New("can't make user copy")
View Source
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

func PackBlock

func PackBlock(block *Block) ([]byte, error)

PackBlock return encrypted data + mac as []byte

func UnpackBlock

func UnpackBlock(data []byte) ([]byte, []byte, []byte, error)

UnpackBlock get blob of data and split to (data, mac, oldMac, error) of block

Types

type Block

type Block struct {
	// contains filtered or unexported fields
}

Block wrap C struct of hermes block

func NewBlockFromData

func NewBlockFromData(user *User, id, rawData, meta []byte) (*Block, error)

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) GetData

func (block *Block) GetData() []byte

GetData return decrypted data of block

func (*Block) GetEncryptedData

func (block *Block) GetEncryptedData() []byte

GetEncryptedData return encrypted data of block

func (*Block) GetEncryptedDataLength

func (block *Block) GetEncryptedDataLength() int

GetEncryptedDataLength return length of decrypted data

func (*Block) GetId

func (block *Block) GetId() []byte

GetId return id of block

func (*Block) GetMac

func (block *Block) GetMac() []byte

GetMac return mac of block

func (*Block) GetMacLength

func (block *Block) GetMacLength() int

GetMacLength return mac length

func (*Block) GetMeta

func (block *Block) GetMeta() []byte

GetMeta return meta of block

func (*Block) GetOldMac

func (block *Block) GetOldMac() []byte

GetOldMac return block's oldMac or nil

func (*Block) GetReadToken

func (block *Block) GetReadToken() (*Token, error)

GetReadToken return read token that was generated after creation new block or after initialization with read token

func (*Block) GetUser

func (block *Block) GetUser() (*User, error)

GetUser return user of block

func (*Block) GetWriteToken

func (block *Block) GetWriteToken() (*Token, error)

GetWriteToken return write token that was generated after creation new block or after initialization with write token

func (*Block) HasWriteToken

func (block *Block) HasWriteToken() bool

HasWriteToken return true if block has related write token

func (*Block) SetOldMac

func (block *Block) SetOldMac(oldMac []byte)

SetOldMac set oldMac to block

func (*Block) Update

func (block *Block) Update(data, meta []byte) error

Update update data and meta in block

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

func NewHermesBuffer(data []byte) (*Buffer, error)

NewHermesBuffer return new *Buffer that wraps data

func (*Buffer) GetData

func (buffer *Buffer) GetData() []byte

GetData return data of buffer as byte slice

type Token

type Token struct {
	// contains filtered or unexported fields
}

Token wrap mid_hermes_ll_token_t C struct

func NewToken

func NewToken(ownerUser *User) (*Token, error)

NewToken generate new token

func NewTokenFromEncryptedBytes

func NewTokenFromEncryptedBytes(encryptedTokenData []byte, user, ownerUser *User) (*Token, error)

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) GetData

func (token *Token) GetData() []byte

GetData return decrypted token

func (*Token) GetEncryptedData

func (token *Token) GetEncryptedData() []byte

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

func (*Token) TokenForUser

func (token *Token) TokenForUser(userFor *User, ownerUser *User) (*Token, error)

TokenForUser return new token encrypted for userFor

type User

type User struct {
	// contains filtered or unexported fields
}

User wraps mid_hermes_ll_user_t C struct

func NewUser

func NewUser(id, privateKey, publicKey []byte) (*User, error)

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

func (user *User) Copy() (*User, error)

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

func (*User) GetId

func (user *User) GetId() []byte

func (*User) GetPublicKey

func (user *User) GetPublicKey() []byte

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL