gohermes

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.

This file is a part of Hermes-core.

Hermes-core is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Hermes-core is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with Hermes-core. If not, see <http://www.gnu.org/licenses/>.

This file is a part of Hermes-core.

Hermes-core is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Hermes-core is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with Hermes-core. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	READ_ACCESS  = 0
	WRITE_ACCESS = 1
)

Variables

View Source
var ErrCAlloc = errors.New("can't allocate memory")
View Source
var ErrEmptyParameter = errors.New("empty parameter")
View Source
var ErrIncorrectRightsValue = errors.New("used incorrect rights value")
View Source
var ErrInvalidDocumentId = errors.New("invalid document id")
View Source
var ErrInvalidUserId = errors.New("invalid user id")
View Source
var ErrKeyStoreAdd = errors.New("add command - Failed")
View Source
var ErrKeyStoreDelete = errors.New("delete command - Failed")
View Source
var ErrKeyStoreGet = errors.New("get command - Failed")
View Source
var ErrKeyStoreGetIndexedRights = errors.New("getIndexedRights command - Failed")
View Source
var ErrMacNotMatched = errors.New("mac not matched")
View Source
var ErrPublicKeyNotFound = errors.New("public key not found")
View Source
var ErrUserCredentialsExists = errors.New("user's credentials already exists")

Functions

func CArrayToSlice

func CArrayToSlice(buffer unsafe.Pointer, bufferLength int) []byte

CArrayToSlice return buffer as byte slice with len/cap equals to bufferLength

func GeneralKeystoreTest

func GeneralKeystoreTest(store KeyStore, t *testing.T)

GeneralKeystoreTest test keystore implementation on standard behaviour and can be used by custom implementations for testing

func SetOutBufferPointerFromByteSlice

func SetOutBufferPointerFromByteSlice(value []byte, outBuffer, outBufferLength unsafe.Pointer) error

SetOutBufferPointerFromByteSlice allocate memory, set pointer of memory into outBuffer, copy value to outBuffer and set size of memory to outBufferLength

Types

type CredentialStore

type CredentialStore interface {
	GetPublicKey(userId []byte) ([]byte, error)
	GetUsersList() ([][]byte, error)
	Close() error
}

CredentialStore interface of hermes-core credential store and should be implemented by go implementations

type DataStore

type DataStore interface {
	// AddBlock return block id or error
	AddBlock(data, meta, mac []byte) ([]byte, error)
	// AddBlockWithId return id or error
	AddBlockWithId(id, data, meta, mac []byte) ([]byte, error)
	// ReadBlock return data and meta data of block or error
	ReadBlock(id []byte) ([]byte, []byte, error)
	// ReadBlockMac return mac of block
	ReadBlockMac(id []byte) ([]byte, error)
	// UpdateBlock only if current block mac == oldMac
	UpdateBlock(id, data, meta, mac, oldMac []byte) error
	// DeleteBlock only if current block mac == oldMac
	DeleteBlock(id []byte, oldMac []byte) error
	// Close any implementation related resources
	Close() error
}

DataStore interface of hermes-core data store and should be implemented by go implementations

type KeyStore

type KeyStore interface {
	Get(docId, userId []byte, isUpdate int) ([]byte, []byte, error) // key, ownerId, error
	Add(docId, userId, key, ownerId []byte, isUpdate int) error
	Delete(docId, userId []byte, isUpdate int) error
	GetIndexedRights(blockId []byte, index int) ([]byte, int, error)
	Close() error
}

KeyStore interface of hermes-core key store and should be implemented by go implementations

type MidHermes

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

MidHermes used to pass Go function call to C

func NewMidHermes

func NewMidHermes(wrapper MidHermesWrapper) (*MidHermes, error)

NewMidHermes return new MidHermes

func (*MidHermes) AddBlock

func (mh *MidHermes) AddBlock(id []byte, data []byte, meta []byte) error

func (*MidHermes) Close

func (mh *MidHermes) Close() error

func (*MidHermes) DeleteBlock

func (mh *MidHermes) DeleteBlock(id []byte) error

func (*MidHermes) GrantReadAccess

func (mh *MidHermes) GrantReadAccess(id []byte, for_user []byte) error

func (*MidHermes) GrantWriteAccess

func (mh *MidHermes) GrantWriteAccess(id []byte, for_user []byte) error

func (*MidHermes) ReadBlock

func (mh *MidHermes) ReadBlock(id []byte) ([]byte, []byte, error)

func (*MidHermes) RevokeReadAccess

func (mh *MidHermes) RevokeReadAccess(id []byte, for_user []byte) error

func (*MidHermes) RevokeWriteAccess

func (mh *MidHermes) RevokeWriteAccess(id []byte, for_user []byte) error

func (*MidHermes) RotateBlock

func (mh *MidHermes) RotateBlock(id []byte) error

func (*MidHermes) UpdateBlock

func (mh *MidHermes) UpdateBlock(id []byte, data []byte, meta []byte) error

type MidHermesWrapper

type MidHermesWrapper interface {
	GetMidHermes() unsafe.Pointer
	Close() error
}

MidHermesWrapper hide fetching C pointer to mid_hermes from go wrappers

Directories

Path Synopsis
midhermes
rpc

Jump to

Keyboard shortcuts

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