github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/go/apps/mixnet/consts.go (about) 1 // Copyright (c) 2016, Google Inc. All rights reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package mixnet 16 17 import ( 18 "errors" 19 "time" 20 21 "golang.org/x/crypto/nacl/box" 22 ) 23 24 const ( 25 // CellBytes specifies the length of a cell. 26 CellBytes = 1 << 10 27 28 // MaxMsgBytes specifies the maximum length of a message. 29 MaxMsgBytes = 1 << 16 30 ) 31 32 const ( 33 // Update directory every x amount of time 34 DefaultUpdateFrequency = 3600 * time.Second 35 DefaultHopCount = 2 36 DefaultTimeout = 10 * time.Second 37 ) 38 39 const ( 40 msgCell = iota 41 dirCell 42 ) 43 44 const ( 45 ID_SIZE = 8 46 LEN_SIZE = 8 47 BODY_SIZE = CellBytes - BODY - box.Overhead - 24 48 ) 49 50 const ( 51 ID = 0 52 TYPE = ID + ID_SIZE 53 BODY = 9 54 ) 55 56 var errCellLength = errors.New("incorrect cell length") 57 var errCellType = errors.New("incorrect cell type") 58 var errBadCellType = errors.New("unrecognized cell type") 59 var errBadDirective = errors.New("received bad directive") 60 var errMsgLength = errors.New("message too long") 61 62 var dirCreated = &Directive{Type: DirectiveType_CREATED.Enum()} 63 var dirDestroy = &Directive{Type: DirectiveType_DESTROY.Enum()} 64 var dirDestroyed = &Directive{Type: DirectiveType_DESTROYED.Enum()}