EXTRA_CFLAGS = -pthread
EXTRA_LDFLAGS =
-EXTRA_LIBS = -pthread
+EXTRA_LIBS = -pthread -lcrypto
.PHONY: all clean
all: ./mandshurica
-./mandshurica: ./main.o ./log.o ./config.o ./util.o ./template.o ./file.o ./db.o
+./mandshurica: ./main.o ./log.o ./config.o ./util.o ./template.o ./file.o ./db.o ./crypto.o
$(CC) $(LDFLAGS) $(EXTRA_LDFLAGS) -o $@ $^ $(LIBS) $(EXTRA_LIBS)
./main.o: ./main.c ./mandshurica.h
--- /dev/null
+/* $Id$ */
+/* --- START LICENSE --- */
+/* -------------------------------------------------------------------------- */
+/* Mandshurica - Build Automation */
+/* -------------------------------------------------------------------------- */
+/* Copyright (c) 2024 Nishi. */
+/* Redistribution and use in source and binary forms, with or without modific */
+/* ation, are permitted provided that the following conditions are met: */
+/* 1. Redistributions of source code must retain the above copyright noti */
+/* ce, this list of conditions and the following disclaimer. */
+/* 2. Redistributions in binary form must reproduce the above copyright n */
+/* otice, this list of conditions and the following disclaimer in the documen */
+/* tation and/or other materials provided with the distribution. */
+/* 3. Neither the name of the copyright holder nor the names of its contr */
+/* ibutors may be used to endorse or promote products derived from this softw */
+/* are without specific prior written permission. */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS */
+/* " AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, TH */
+/* E IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPO */
+/* SE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS */
+/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CON */
+/* SEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITU */
+/* TE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPT */
+/* ION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, S */
+/* TRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN AN */
+/* Y WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY */
+/* OF SUCH DAMAGE. */
+/* -------------------------------------------------------------------------- */
+/* --- END LICENSE --- */
+
+#include "ms_crypto.h"
+
+#include <stdlib.h>
+
+#include <openssl/sha.h>
+
+char num2hex(int num) {
+ if(num >= 0 && num <= 9) return num + '0';
+ if(num >= 10 && num <= 15) return num - 10 + 'a';
+}
+
+char* mandshurica_sha512(const char* pwd) {
+ SHA512_CTX ctx;
+ unsigned char buffer[64];
+ SHA512_Init(&ctx);
+ SHA512_Update(&ctx, pwd, strlen(pwd));
+ SHA512_Final(buffer, &ctx);
+ char* buf = malloc(129);
+ int i;
+ for(i = 0; i < 64; i++) {
+ buf[i * 2 + 0] = num2hex((buffer[i] & 0xf0) >> 4);
+ buf[i * 2 + 1] = num2hex((buffer[i] & 0x0f) >> 0);
+ }
+ buf[128] = 0;
+ printf("%s\n", buf);
+ return buf;
+}
--- /dev/null
+/* $Id$ */
+/* --- START LICENSE --- */
+/* -------------------------------------------------------------------------- */
+/* Mandshurica - Build Automation */
+/* -------------------------------------------------------------------------- */
+/* Copyright (c) 2024 Nishi. */
+/* Redistribution and use in source and binary forms, with or without modific */
+/* ation, are permitted provided that the following conditions are met: */
+/* 1. Redistributions of source code must retain the above copyright noti */
+/* ce, this list of conditions and the following disclaimer. */
+/* 2. Redistributions in binary form must reproduce the above copyright n */
+/* otice, this list of conditions and the following disclaimer in the documen */
+/* tation and/or other materials provided with the distribution. */
+/* 3. Neither the name of the copyright holder nor the names of its contr */
+/* ibutors may be used to endorse or promote products derived from this softw */
+/* are without specific prior written permission. */
+/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS */
+/* " AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, TH */
+/* E IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPO */
+/* SE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS */
+/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CON */
+/* SEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITU */
+/* TE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPT */
+/* ION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, S */
+/* TRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN AN */
+/* Y WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY */
+/* OF SUCH DAMAGE. */
+/* -------------------------------------------------------------------------- */
+/* --- END LICENSE --- */
+
+#ifndef __MANDSHURICA_MS_CRYPTO_H__
+#define __MANDSHURICA_MS_CRYPTO_H__
+
+char* mandshurica_sha512(const char* pwd);
+
+#endif
Term::ReadKey::ReadMode("noecho");
-my $password = Term::ReadKey::ReadLine(0);
+chomp(my $password = Term::ReadKey::ReadLine(0));
print STDERR "\n";
print STDERR "Verify Password: ";
-my $verify = Term::ReadKey::ReadLine(0);
+chomp(my $verify = Term::ReadKey::ReadLine(0));
print STDERR "\n";