Alexander Sayapin Teacher's site

Using homemade OpenPGP Smart Card

Posted on Wed 01 April 2020

In Общие вопросы.

tags: setup ssh openpgp pgp smartcard


What we want to get?

A bit more secure way to log-in to the remote server with ssh using st-link v.2 as an OpenPGP smartcard.

Hardware preparation

Accordig to the great articles: article1, article2

Steps

Prepare the system for PGP using

sudo apt update
sudo apt install -y wget gnupg2 gnupg-agent dirmngr cryptsetup scdaemon pcscd secure-delete hopenpgp-tools yubikey-personalization
sudo apt install opensc-pkcs11
sudo apt install monkeysphere
sudo apt-get install opensc pcscd paperkey haveged gnupg2 gnupg-agent pinentry-curses libccid scdaemon libksba8 libpth20
sudo apt install opensc

Prepare the system for the firmaware compilation

sudo apt install gcc-arm-none-eabi
sudo apt install libnewlib-arm-none-eabi
sudo apt install openocd

Get and compile the firmware v.1:

sudo cp /usr/share/openocd/scripts/target/stm32f1x.cfg /usr/share/openocd/scripts/target/cks32f1x.cfg
sudo sed -i 's/0x1ba01477/0x2ba01477/' /usr/share/openocd/scripts/target/cks32f1x.cfg
git clone https://salsa.debian.org/gnuk-team/gnuk/gnuk.git
cd gnuk/
git submodule update --init
git checkout STABLE-BRANCH-1-0
cd src
./configure --vidpid="234b:0000" --enable-keygen
make

Flash the firmware to the device

openocd -f interface/stlink-v2.cfg -f target/cks32f1x.cfg -c 'init; reset init; stm32f1x unlock 0; program ./gnuk.elf verify reset exit'

Lock the device memory

openocd -f interface/stlink-v2.cfg -f target/cks32f1x.cfg -c init -c "reset halt" -c "stm32f1x lock 0" -c reset -c exit

Generate the key on the device:

gpg --card-edit
gpg/card> admin
gpg/card> generate

It would take time, so we can import existing key:

cp id_rsa id_rsa.tmp
chmod 600 id_rsa.tmp
ssh-keygen -p -N "" -m pem -f id_rsa.tmp
pem2openpgp temporary_id < id_rsa.tmp | gpg --import
gpg -K

tags

алфавит (1) архитектура ЭВМ (3) asp.net (1) бгд (22) бисв (23) бкб (22) бме (22) бпэ (23) бпэз (4) бпэзу (1) бпм (19) бпм объявления (7) certbot (1) cheatsheet (1) checkinstall (1) csv (1) дискретная математика (25) экзамен (1) embedded rust (2) english (1) формальные грамматики (1) gdb (2) язык (1) исследование операций (1) jupyter (1) критерии (2) курсовая работа (2) lighttpd (2) low-latency (1) machine learning (3) make (1) make install (1) markdown (1) машинное обучение (1) математическая лингвистика (1) математическая логика (1) математическая статистика (1) Математические основы кмпьютерной графики (1) Математические основы компьютерного моделирования (1) Математические основы компьютерной графики (1) Методы оптимизации (17) методы оптмимизации (1) методы принятия решений (1) миа (6) мии (8) мик (7) мим (7) мио (4) мип (9) мит (44) миу (13) миз (12) ml (1) mono (1) мпм (6) natural language processing (1) nlp (1) nucleo (2) объявления (31) оформление (2) openocd (2) openpgp (1) pandas (1) pgp (1) подтверждение вывода (1) programming (3) python (3) robot (1) robotics (2) setup (6) шпаргалка (1) smartcard (1) ssh (1) ssl (1) STM32 (2) streaming (1) строка (1) тб (21) teaching (1) teaching statement (1) Теоретические основы цифровой обработки изображений (2) тест (1) учебник (1) up board (1) video (1) вкр (2) xls (1)