aboutsummaryrefslogtreecommitdiff
path: root/internal/stupidgcm/without_openssl.go
blob: deac3423b6885efdf77c894cd08b620b58718ee4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// +build without_openssl

package stupidgcm

import (
	"fmt"
	"os"

	"github.com/rfjakob/gocryptfs/internal/exitcodes"
)

type StupidGCM struct{}

const (
	// BuiltWithoutOpenssl indicates if openssl been disabled at compile-time
	BuiltWithoutOpenssl = true
)

func errExit() {
	fmt.Fprintln(os.Stderr, "gocryptfs has been compiled without openssl support but you are still trying to use openssl")
	os.Exit(exitcodes.OpenSSL)
}

func New(_ []byte, _ bool) *StupidGCM {
	errExit()
	// Never reached
	return &StupidGCM{}
}

func (g *StupidGCM) NonceSize() int {
	errExit()
	return -1
}

func (g *StupidGCM) Overhead() int {
	errExit()
	return -1
}

func (g *StupidGCM) Seal(_, _, _, _ []byte) []byte {
	errExit()
	return nil
}

func (g *StupidGCM) Open(_, _, _, _ []byte) ([]byte, error) {
	errExit()
	return nil, nil
}

func (g *StupidGCM) Wipe() {
	errExit()
}