libgocryptfs/internal/stupidgcm/without_openssl.go
Jakob Unterwurzacher d5adde1eeb exitcodes: pull all exit code definitions into the package
This commit defines all exit codes in one place in the exitcodes
package.

Also, it adds a test to verify the exit code on incorrect
password, which is what SiriKali cares about the most.

Fixes https://github.com/rfjakob/gocryptfs/issues/77 .
2017-05-07 22:16:22 +02:00

49 lines
813 B
Go

// +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
}