totp

Simple cli tool for storing TOTP secrets and generating tokens
git clone https://git.inz.fi/totp/
Log | Files | Refs | Submodules

commit 05e32ad33737a0d76c628f31ccea0fd841ee85d8
parent 493bc6f598be675bef1950351a64013e2d0d3834
Author: Santtu Lakkala <inz@inz.fi>
Date:   Fri,  2 Jul 2021 09:42:42 +0300

Improve make compatibility, add dtotp wrapper

Diffstat:
MMakefile | 24++++++++++++------------
Adtotp | 15+++++++++++++++
2 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,20 +1,20 @@ -CFLAGS := -g -W -Wall -std=c99 +CFLAGS = -g -W -Wall -std=c99 AES_CFLAGS += -DECB=0 -DCBC=1 -DCTR=0 -DAES256=1 -SOURCES := sha1.c sha256.c sha512.c tiny-AES-c/aes.c main.c util.c -OBJS := $(patsubst %.c,%.o,$(SOURCES)) -TEST_SOURCES := sha1.c sha256.c sha512.c util.c test.c -TEST_OBJS := $(patsubst %.c,%.o,$(TEST_SOURCES)) +SOURCES = sha1.c sha256.c sha512.c tiny-AES-c/aes.c main.c util.c +OBJS = ${SOURCES:.c=.o} +TEST_SOURCES = sha1.c sha256.c sha512.c util.c test.c +TEST_OBJS = ${TEST_SOURCES:.c=.o} all: totp -totp: $(OBJS) - $(CC) -o $@ $(OBJS) $(LDFLAGS) +totp: ${OBJS} + ${CC} -o $@ ${OBJS} ${LDFLAGS} -test: $(TEST_OBJS); - $(CC) -o $@ $(TEST_OBJS) $(LDFLAGS) +test: ${TEST_OBJS}; + ${CC} -o $@ ${TEST_OBJS} ${LDFLAGS} -%.o: %.c - $(CC) -c $< -o $@ $(CFLAGS) $(AES_CFLAGS) +.c.o: + ${CC} -c $< -o $@ ${CFLAGS} ${AES_CFLAGS} clean: - rm $(OBJS) + rm ${OBJS} diff --git a/dtotp b/dtotp @@ -0,0 +1,15 @@ +#!/bin/sh + +KEY=$(dmenu -p 'Enter passphrase: ' -sb '#000000' -sf '#c6f24b' -nb '#000000' -nf '#000000' </dev/null) +ID= +if [ "$1" ]; then + ID="*$1*" +else + ID=$(totp -K - -l <<FOO | cut -d ' ' -f1 | dmenu -sb '#000000' -sf '#c6f24b' -nb '#000000' -nf '#c0c0c0' +$KEY +FOO + ) +fi +totp -K - -t "$ID" << FOO | head -n1 | tr -d '\r\n' | xclip -selection clipboard +$KEY +FOO