From 4f7b10f59b97b45d42577c4d6d33958d9565aef7 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Mon, 12 Jul 2010 12:57:11 +0200 Subject: Initial additions to have PK encryption/decryption. Separated operations on keys to read/write to prevent overwriting a key while using it. Several other cleanups. --- userspace/Makefile | 13 ++++++++----- userspace/setkey.c | 5 +++++ 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'userspace') diff --git a/userspace/Makefile b/userspace/Makefile index 1a95ac7..fddefb3 100644 --- a/userspace/Makefile +++ b/userspace/Makefile @@ -1,9 +1,12 @@ -KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build +CC = gcc +CFLAGS = -Wall -g -O2 -hostprogs := setkey -setkey-objs := setkey.o +progs := ncr-setkey -all: $(hostprogs) +all: $(progs) + +ncr-setkey: setkey.c + $(CC) $(CFLAGS) $< -o $@ clean: - rm -f *.o *~ setkey + rm -f *.o *~ ncr-setkey diff --git a/userspace/setkey.c b/userspace/setkey.c index 535773d..d0a2b62 100644 --- a/userspace/setkey.c +++ b/userspace/setkey.c @@ -47,6 +47,11 @@ int main(int argc, char** argv) memset(&key, 0, sizeof(key)); fp = fopen(argv[1], "r"); + if (fp == NULL) { + fprintf(stderr, "Cannot read %s\n", argv[1]); + exit(1); + } + size = fread(key.key, 1, sizeof(key.key), fp); if (size < 16) { fprintf(stderr, "Illegal key!\n"); -- cgit