Commit 6ddf765d authored by Milan Broz's avatar Milan Broz

Remove example covered by cryptsetup already.

parent 38d83c27
......@@ -4,14 +4,11 @@ LDLIBS=-ljson-c -luuid -lgcrypt -ldevmapper -lpthread -lssh
CC=gcc
TARGET2=keyslot_test_remote_pass
TARGET4=keyslot_add_by_key
SOURCES=keyslot_test.c
OBJECTS=$(SOURCES:.c=.o)
SOURCES2=keyslot_test_remote_pass.c
OBJECTS2=$(SOURCES2:.c=.o)
SOURCES4=keyslot_add_by_key.c
OBJECTS4=$(SOURCES4:.c=.o)
all: $(TARGET) $(TARGET2) $(TARGET4)
......@@ -21,10 +18,7 @@ $(TARGET): $(OBJECTS) ../../.libs/libcryptsetup.a
$(TARGET2): $(OBJECTS2) ../../.libs/libcryptsetup.a
$(CC) -o $@ $^ $(LDLIBS)
$(TARGET4): $(OBJECTS4) ../../.libs/libcryptsetup.a
$(CC) -o $@ $^ $(LDLIBS)
clean:
rm -f *.o *~ core $(TARGET) $(TARGET2) $(TARGET4)
rm -f *.o *~ core $(TARGET) $(TARGET2)
.PHONY: clean
/*
* Prototype LUKS2 utility for keyslots unassigned to volume
*
* Copyright (C) 2017-2018, Red Hat, Inc. All rights reserved.
* Copyright (C) 2017-2018, Ondrej Kozina <okozina@redhat.com>
*
* Use:
* - generate LUKS2 device
* - add new keyslot unassigned to segment using this example
* (it'll generate random key with same size as volume key)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "libcryptsetup.h"
int main(int argc, char **argv)
{
int r;
struct crypt_device *cd;
if (argc < 3)
return EXIT_FAILURE;
if (crypt_init(&cd, argv[1])) {
fprintf(stderr, "Failed to init device %s.\n", argv[1]);
return EXIT_FAILURE;
}
if (crypt_load(cd, CRYPT_LUKS2, NULL)) {
fprintf(stderr, "Failed to load luks2 device %s.\n", argv[1]);
crypt_free(cd);
return EXIT_FAILURE;
}
r = crypt_keyslot_add_by_key(cd, CRYPT_ANY_SLOT, NULL,
crypt_get_volume_key_size(cd), argv[2],
strlen(argv[2]),
CRYPT_VOLUME_KEY_NO_SEGMENT);
if (r < 0)
fprintf(stderr, "Failed to load luks2 device %s.\n", argv[1]);
crypt_free(cd);
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment