blob: 73110a6451325eb675c2de9b15cade951a90fb8a [file] [log] [blame]
Jiri Simsad7616c92015-03-24 23:44:30 -07001// Copyright 2015 The Vanadium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
Jiri Simsa5293dcb2014-05-10 09:56:38 -07005package crypto
6
Suharsh Sivakumardcc11d72015-05-11 12:19:20 -07007import "v.io/x/ref/runtime/internal/lib/iobuf"
Jiri Simsa5293dcb2014-05-10 09:56:38 -07008
9// NewNullCrypter returns a Crypter that does no encryption/decryption.
10func NewNullCrypter() Crypter { return null{} }
11
Jungho Ahn19e84b22015-05-18 13:22:27 -070012// NewNullCrypterWithChannelBinding returns a null Crypter with a channel binding.
13func NewNullCrypterWithChannelBinding(channelBinding []byte) Crypter {
14 return null{channelBinding}
15}
16
17type null struct {
18 channelBinding []byte
19}
Jiri Simsa5293dcb2014-05-10 09:56:38 -070020
Andres Erbsenffa45742014-08-13 10:13:11 -070021func (null) Encrypt(src *iobuf.Slice) (*iobuf.Slice, error) { return src, nil }
22func (null) Decrypt(src *iobuf.Slice) (*iobuf.Slice, error) { return src, nil }
Jungho Ahn19e84b22015-05-18 13:22:27 -070023func (n null) ChannelBinding() []byte { return n.channelBinding }
24func (n null) String() string {
25 if n.channelBinding == nil {
26 return "Null"
27 }
28 return "Null(ChannelBinding)"
29}