summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2017-09-15 08:14:38 +0200
committerChristian Pointner <equinox@anytun.org>2017-09-15 08:14:38 +0200
commit701cee620335ac3157d1aa6254be772498b2ab07 (patch)
tree067f98eac51b279fc72b30f3f51c7b71f5d114d6
parentsome more tests (diff)
added some interfaces and a skeleton squence window
-rw-r--r--satp/crypto-kd.go55
-rw-r--r--satp/crypto-transport.go36
-rw-r--r--satp/sequence-window.go61
3 files changed, 152 insertions, 0 deletions
diff --git a/satp/crypto-kd.go b/satp/crypto-kd.go
new file mode 100644
index 0000000..208c4a9
--- /dev/null
+++ b/satp/crypto-kd.go
@@ -0,0 +1,55 @@
+//
+// Copyright (c) 2017 anygone contributors (see AUTHORS file)
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of anygone nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+package satp
+
+type KeyDirection int
+type KeyUsage int
+type Label uint32
+
+const (
+ KeyLeft KeyDirection = iota
+ KeyRight
+
+ Encrypt KeyUsage = iota
+ Salt
+ Auth
+
+ LabelLeftEncrypt = 0x356A192B
+ LabelRightEncrypt = 0xDA4B9237
+ LabelLeftSalt = 0x77DE68DA
+ LabelRightSalt = 0x1B645389
+ LabelLeftAuth = 0xAC3478D6
+ LabelRightAuth = 0xC1DFD96E
+)
+
+type KeyDerivation interface {
+ Generate(dir KeyDirection, usage KeyUsage, sequenceNumber uint32) ([]byte, error)
+}
diff --git a/satp/crypto-transport.go b/satp/crypto-transport.go
new file mode 100644
index 0000000..56377da
--- /dev/null
+++ b/satp/crypto-transport.go
@@ -0,0 +1,36 @@
+//
+// Copyright (c) 2017 anygone contributors (see AUTHORS file)
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of anygone nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+package satp
+
+type TransportCrypto interface {
+ EncryptAndAuthenticate() error
+ VerifyAndDecrypt() error
+}
diff --git a/satp/sequence-window.go b/satp/sequence-window.go
new file mode 100644
index 0000000..c74ca62
--- /dev/null
+++ b/satp/sequence-window.go
@@ -0,0 +1,61 @@
+//
+// Copyright (c) 2017 anygone contributors (see AUTHORS file)
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// * Neither the name of anygone nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+
+package satp
+
+import (
+ "errors"
+)
+
+type SequenceWindow struct {
+ size int
+}
+
+func (w *SequenceWindow) Check(sequenceNumber uint32) (bool, error) {
+ if w.size == 0 {
+ return false, nil
+ }
+ return false, nil
+}
+
+func (w *SequenceWindow) CheckAndSet(sequenceNumber uint32) (bool, error) {
+ if w.size == 0 {
+ return false, nil
+ }
+ return false, nil
+}
+
+func NewSequenceWindow(size int) (w *SequenceWindow, err error) {
+ if size < 0 {
+ return nil, errors.New("invalid sequence window size")
+ }
+ w = &SequenceWindow{size: size}
+ return
+}