Jiri Simsa | d7616c9 | 2015-03-24 23:44:30 -0700 | [diff] [blame] | 1 | // 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 Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 5 | package crypto |
| 6 | |
Suharsh Sivakumar | dcc11d7 | 2015-05-11 12:19:20 -0700 | [diff] [blame] | 7 | import "v.io/x/ref/runtime/internal/lib/iobuf" |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 8 | |
| 9 | // NewNullCrypter returns a Crypter that does no encryption/decryption. |
| 10 | func NewNullCrypter() Crypter { return null{} } |
| 11 | |
Jungho Ahn | 19e84b2 | 2015-05-18 13:22:27 -0700 | [diff] [blame] | 12 | // NewNullCrypterWithChannelBinding returns a null Crypter with a channel binding. |
| 13 | func NewNullCrypterWithChannelBinding(channelBinding []byte) Crypter { |
| 14 | return null{channelBinding} |
| 15 | } |
| 16 | |
| 17 | type null struct { |
| 18 | channelBinding []byte |
| 19 | } |
Jiri Simsa | 5293dcb | 2014-05-10 09:56:38 -0700 | [diff] [blame] | 20 | |
Andres Erbsen | ffa4574 | 2014-08-13 10:13:11 -0700 | [diff] [blame] | 21 | func (null) Encrypt(src *iobuf.Slice) (*iobuf.Slice, error) { return src, nil } |
| 22 | func (null) Decrypt(src *iobuf.Slice) (*iobuf.Slice, error) { return src, nil } |
Jungho Ahn | 19e84b2 | 2015-05-18 13:22:27 -0700 | [diff] [blame] | 23 | func (n null) ChannelBinding() []byte { return n.channelBinding } |
| 24 | func (n null) String() string { |
| 25 | if n.channelBinding == nil { |
| 26 | return "Null" |
| 27 | } |
| 28 | return "Null(ChannelBinding)" |
| 29 | } |