2020-05-04 11:00:25 +00:00
|
|
|
package service
|
|
|
|
|
2020-05-04 16:33:18 +00:00
|
|
|
import (
|
|
|
|
"crypto/ecdsa"
|
|
|
|
)
|
|
|
|
|
2020-05-04 11:00:25 +00:00
|
|
|
// NodeRole to identify in Bootstrap service.
|
|
|
|
type NodeRole int32
|
|
|
|
|
|
|
|
// TTLCondition is a function type that used to verify that TTL values match a specific criterion.
|
|
|
|
// Nil error indicates compliance with the criterion.
|
|
|
|
type TTLCondition func(uint32) error
|
|
|
|
|
|
|
|
// RawSource is an interface of the container of a boolean Raw value with read access.
|
|
|
|
type RawSource interface {
|
|
|
|
GetRaw() bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// RawContainer is an interface of the container of a boolean Raw value.
|
|
|
|
type RawContainer interface {
|
|
|
|
RawSource
|
|
|
|
SetRaw(bool)
|
|
|
|
}
|
|
|
|
|
2020-05-06 12:32:13 +00:00
|
|
|
// VersionSource is an interface of the container of a numerical Version value with read access.
|
2020-05-04 11:00:25 +00:00
|
|
|
type VersionSource interface {
|
|
|
|
GetVersion() uint32
|
|
|
|
}
|
|
|
|
|
|
|
|
// VersionContainer is an interface of the container of a numerical Version value.
|
|
|
|
type VersionContainer interface {
|
|
|
|
VersionSource
|
|
|
|
SetVersion(uint32)
|
|
|
|
}
|
|
|
|
|
|
|
|
// EpochSource is an interface of the container of a NeoFS epoch number with read access.
|
|
|
|
type EpochSource interface {
|
|
|
|
GetEpoch() uint64
|
|
|
|
}
|
|
|
|
|
|
|
|
// EpochContainer is an interface of the container of a NeoFS epoch number.
|
|
|
|
type EpochContainer interface {
|
|
|
|
EpochSource
|
|
|
|
SetEpoch(uint64)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TTLSource is an interface of the container of a numerical TTL value with read access.
|
|
|
|
type TTLSource interface {
|
|
|
|
GetTTL() uint32
|
|
|
|
}
|
|
|
|
|
|
|
|
// TTLContainer is an interface of the container of a numerical TTL value.
|
|
|
|
type TTLContainer interface {
|
|
|
|
TTLSource
|
|
|
|
SetTTL(uint32)
|
|
|
|
}
|
|
|
|
|
2020-05-04 11:37:14 +00:00
|
|
|
// SeizedMetaHeaderContainer is an interface of container of RequestMetaHeader that can be cut and restored.
|
|
|
|
type SeizedMetaHeaderContainer interface {
|
|
|
|
CutMeta() RequestMetaHeader
|
|
|
|
RestoreMeta(RequestMetaHeader)
|
|
|
|
}
|
|
|
|
|
2020-05-04 11:00:25 +00:00
|
|
|
// RequestMetaContainer is an interface of a fixed set of request meta value containers.
|
|
|
|
// Contains:
|
|
|
|
// - TTL value;
|
|
|
|
// - NeoFS epoch number;
|
|
|
|
// - Protocol version;
|
|
|
|
// - Raw toggle option.
|
|
|
|
type RequestMetaContainer interface {
|
|
|
|
TTLContainer
|
|
|
|
EpochContainer
|
|
|
|
VersionContainer
|
|
|
|
RawContainer
|
|
|
|
}
|
|
|
|
|
2020-05-04 11:37:14 +00:00
|
|
|
// SeizedRequestMetaContainer is a RequestMetaContainer with seized meta.
|
|
|
|
type SeizedRequestMetaContainer interface {
|
|
|
|
RequestMetaContainer
|
|
|
|
SeizedMetaHeaderContainer
|
|
|
|
}
|
|
|
|
|
2020-05-04 11:00:25 +00:00
|
|
|
// VerbSource is an interface of the container of a token verb value with read access.
|
|
|
|
type VerbSource interface {
|
|
|
|
GetVerb() Token_Info_Verb
|
|
|
|
}
|
|
|
|
|
|
|
|
// VerbContainer is an interface of the container of a token verb value.
|
|
|
|
type VerbContainer interface {
|
|
|
|
VerbSource
|
|
|
|
SetVerb(Token_Info_Verb)
|
|
|
|
}
|
|
|
|
|
|
|
|
// TokenIDSource is an interface of the container of a token ID value with read access.
|
|
|
|
type TokenIDSource interface {
|
|
|
|
GetID() TokenID
|
|
|
|
}
|
|
|
|
|
|
|
|
// TokenIDContainer is an interface of the container of a token ID value.
|
|
|
|
type TokenIDContainer interface {
|
|
|
|
TokenIDSource
|
|
|
|
SetID(TokenID)
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreationEpochSource is an interface of the container of a creation epoch number with read access.
|
|
|
|
type CreationEpochSource interface {
|
|
|
|
CreationEpoch() uint64
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreationEpochContainer is an interface of the container of a creation epoch number.
|
|
|
|
type CreationEpochContainer interface {
|
|
|
|
CreationEpochSource
|
|
|
|
SetCreationEpoch(uint64)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExpirationEpochSource is an interface of the container of an expiration epoch number with read access.
|
|
|
|
type ExpirationEpochSource interface {
|
|
|
|
ExpirationEpoch() uint64
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExpirationEpochContainer is an interface of the container of an expiration epoch number.
|
|
|
|
type ExpirationEpochContainer interface {
|
|
|
|
ExpirationEpochSource
|
|
|
|
SetExpirationEpoch(uint64)
|
|
|
|
}
|
|
|
|
|
2020-05-08 09:34:16 +00:00
|
|
|
// LifetimeSource is an interface of the container of creation-expiration epoch pair with read access.
|
|
|
|
type LifetimeSource interface {
|
|
|
|
CreationEpochSource
|
|
|
|
ExpirationEpochSource
|
|
|
|
}
|
|
|
|
|
2020-05-08 09:45:16 +00:00
|
|
|
// LifetimeContainer is an interface of the container of creation-expiration epoch pair.
|
2020-05-08 09:34:16 +00:00
|
|
|
type LifetimeContainer interface {
|
|
|
|
CreationEpochContainer
|
|
|
|
ExpirationEpochContainer
|
|
|
|
}
|
|
|
|
|
2020-05-04 11:00:25 +00:00
|
|
|
// SessionKeySource is an interface of the container of session key bytes with read access.
|
|
|
|
type SessionKeySource interface {
|
|
|
|
GetSessionKey() []byte
|
|
|
|
}
|
|
|
|
|
|
|
|
// SessionKeyContainer is an interface of the container of public session key bytes.
|
|
|
|
type SessionKeyContainer interface {
|
|
|
|
SessionKeySource
|
|
|
|
SetSessionKey([]byte)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SignatureSource is an interface of the container of signature bytes with read access.
|
|
|
|
type SignatureSource interface {
|
|
|
|
GetSignature() []byte
|
|
|
|
}
|
|
|
|
|
|
|
|
// SignatureContainer is an interface of the container of signature bytes.
|
|
|
|
type SignatureContainer interface {
|
|
|
|
SignatureSource
|
|
|
|
SetSignature([]byte)
|
|
|
|
}
|
|
|
|
|
2020-05-15 13:03:47 +00:00
|
|
|
// OwnerKeySource is an interface of the container of owner key bytes with read access.
|
|
|
|
type OwnerKeySource interface {
|
|
|
|
GetOwnerKey() []byte
|
|
|
|
}
|
|
|
|
|
|
|
|
// OwnerKeyContainer is an interface of the container of owner key bytes.
|
|
|
|
type OwnerKeyContainer interface {
|
|
|
|
OwnerKeySource
|
|
|
|
SetOwnerKey([]byte)
|
|
|
|
}
|
|
|
|
|
2020-05-04 11:00:25 +00:00
|
|
|
// SessionTokenSource is an interface of the container of a SessionToken with read access.
|
|
|
|
type SessionTokenSource interface {
|
|
|
|
GetSessionToken() SessionToken
|
|
|
|
}
|
|
|
|
|
|
|
|
// SessionTokenInfo is an interface of a fixed set of token information value containers.
|
|
|
|
// Contains:
|
|
|
|
// - ID of the token;
|
|
|
|
// - ID of the token's owner;
|
|
|
|
// - verb of the session;
|
|
|
|
// - address of the session object;
|
2020-05-08 09:34:16 +00:00
|
|
|
// - token lifetime;
|
2020-05-15 13:03:47 +00:00
|
|
|
// - public session key bytes;
|
|
|
|
// - owner's public key bytes.
|
2020-05-04 11:00:25 +00:00
|
|
|
type SessionTokenInfo interface {
|
|
|
|
TokenIDContainer
|
|
|
|
OwnerIDContainer
|
|
|
|
VerbContainer
|
|
|
|
AddressContainer
|
2020-05-08 09:34:16 +00:00
|
|
|
LifetimeContainer
|
2020-05-04 11:00:25 +00:00
|
|
|
SessionKeyContainer
|
2020-05-15 13:03:47 +00:00
|
|
|
OwnerKeyContainer
|
2020-05-04 11:00:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SessionToken is an interface of token information and signature pair.
|
|
|
|
type SessionToken interface {
|
|
|
|
SessionTokenInfo
|
|
|
|
SignatureContainer
|
|
|
|
}
|
2020-05-04 15:52:56 +00:00
|
|
|
|
|
|
|
// SignedDataSource is an interface of the container of a data for signing.
|
|
|
|
type SignedDataSource interface {
|
|
|
|
// Must return the required for signature byte slice.
|
|
|
|
// A non-nil error indicates that the data is not ready for signature.
|
|
|
|
SignedData() ([]byte, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SignedDataReader is an interface of signed data reader.
|
|
|
|
type SignedDataReader interface {
|
|
|
|
// Must return the minimum length of the slice for full reading.
|
2020-05-06 08:44:55 +00:00
|
|
|
// Must return a negative value if the length cannot be calculated.
|
2020-05-04 15:52:56 +00:00
|
|
|
SignedDataSize() int
|
|
|
|
|
|
|
|
// Must behave like Read method of io.Reader and differ only in the reading of the signed data.
|
|
|
|
ReadSignedData([]byte) (int, error)
|
|
|
|
}
|
2020-05-04 16:33:18 +00:00
|
|
|
|
2020-05-06 08:44:55 +00:00
|
|
|
// SignKeyPairAccumulator is an interface of a set of key-signature pairs with append access.
|
|
|
|
type SignKeyPairAccumulator interface {
|
2020-05-04 16:33:18 +00:00
|
|
|
AddSignKey([]byte, *ecdsa.PublicKey)
|
|
|
|
}
|
2020-05-05 10:16:21 +00:00
|
|
|
|
2020-05-06 08:44:55 +00:00
|
|
|
// SignKeyPairSource is an interface of a set of key-signature pairs with read access.
|
|
|
|
type SignKeyPairSource interface {
|
|
|
|
GetSignKeyPairs() []SignKeyPair
|
|
|
|
}
|
|
|
|
|
2020-05-05 10:16:21 +00:00
|
|
|
// SignKeyPair is an interface of key-signature pair with read access.
|
|
|
|
type SignKeyPair interface {
|
|
|
|
SignatureSource
|
|
|
|
GetPublicKey() *ecdsa.PublicKey
|
|
|
|
}
|
|
|
|
|
|
|
|
// DataWithSignature is an interface of data-signature pair with read access.
|
|
|
|
type DataWithSignature interface {
|
|
|
|
SignedDataSource
|
|
|
|
SignatureSource
|
|
|
|
}
|
2020-05-06 08:44:55 +00:00
|
|
|
|
|
|
|
// DataWithSignKeyAccumulator is an interface of data and key-signature accumulator pair.
|
|
|
|
type DataWithSignKeyAccumulator interface {
|
|
|
|
SignedDataSource
|
|
|
|
SignKeyPairAccumulator
|
|
|
|
}
|
|
|
|
|
|
|
|
// DataWithSignKeySource is an interface of data and key-signature source pair.
|
|
|
|
type DataWithSignKeySource interface {
|
|
|
|
SignedDataSource
|
|
|
|
SignKeyPairSource
|
|
|
|
}
|
|
|
|
|
|
|
|
// SignedDataWithToken is an interface of data-token pair with read access.
|
|
|
|
type SignedDataWithToken interface {
|
|
|
|
SignedDataSource
|
|
|
|
SessionTokenSource
|
|
|
|
}
|
|
|
|
|
|
|
|
// DataWithTokenSignAccumulator is an interface of data-token pair with signature write access.
|
|
|
|
type DataWithTokenSignAccumulator interface {
|
|
|
|
SignedDataWithToken
|
|
|
|
SignKeyPairAccumulator
|
|
|
|
}
|
|
|
|
|
|
|
|
// DataWithTokenSignSource is an interface of data-token pair with signature read access.
|
|
|
|
type DataWithTokenSignSource interface {
|
|
|
|
SignedDataWithToken
|
|
|
|
SignKeyPairSource
|
|
|
|
}
|