Outils pour utilisateurs

Outils du site


blog

Notes GPG - Two cards with same subkeys

GPG - carte a puce - utiliser plusieurs cartes avec les mêmes clefs secrètes

Voir :

Backup GPG cards

Voir :

Pb - Error Please insert card with serial number 0001 12345678

$ diff .gnupg.nitrokey/private-keys-v1.d/AF710C976166A34B065DAF48430F30FEE69DA9D9.key .gnupg.yubykey/private-keys-v1.d/AF710C976166A34B065DAF48430F30FEE69DA9D9.key
6c6
<   (#D27600012401030400050000A44B0000# OPENPGP.1))))
---
>   (#D2760001240103040006142373880000# OPENPGP.1))))

$ diff .gnupg.nitrokey/private-keys-v1.d/C98A50CAD33BE20FCC23425F9FAA782B5195A9D2.key .gnupg.yubykey/private-keys-v1.d/C98A50CAD33BE20FCC23425F9FAA782B5195A9D2.key 
6c6
<   (#D27600012401030400050000A44B0000# OPENPGP.2))))
---
>   (#D2760001240103040006142373880000# OPENPGP.2))))
$ gpg --card-status  | grep 'card-no'
                                          card-no: 0006 14237388
                                          card-no: 0006 14237388
$ gpg --card-status | grep "^Application ID"
Application ID ...: D27600012401030400050000A44B0000
$ opensc-tool -l 
# Detected readers (pcsc)
Nr.  Card  Features  Name
0    Yes             Nitrokey Nitrokey Pro (00000000000000000000A44B) 00 00
D276000124010304 00050000A44B0000
D276000124010304 + '0006 14237388' + '0000'
D2760001240103040006142373880000

Voici comment trouver ce numéro

$ opensc-explorer 
OpenSC Explorer version 0.21.0
Using reader with a card: Nitrokey Nitrokey Pro (00000000000000000000A44B) 00 00
OpenSC [3F00]> ls
FileID  Type  Size
 004F    wEF    16
 005E    wEF    19
[0065]    DF    32
[006E]    DF   244
[007A]    DF     5
 00C4    wEF     7
 0101    wEF     0
 0102    wEF     0
 0103    wEF     0
 0104    wEF     0
 5F50    wEF     0
 5F52    wEF    10
 7F21    wEF     0
[A400]    DF     0
 A401    wEF     0
[B600]    DF   136
 B601    wEF   158
[B800]    DF   136
 B801    wEF   158
OpenSC [3F00]> cat 004F
00000000: D2 76 00 01 24 01 03 04 00 05 00 00 A4 4B 00 00 .v..$........K..

Seulement voilà cette manip ne fonctionne pas la Yubikey

$ openpgp-tool -C
Using reader with a card: Yubico YubiKey OTP+FIDO+CCID 00 00
AID:             d2:76:00:01:24:01:03:04:00:06:14:23:73:88:00:00
Version:         3.4
Manufacturer:    Yubico
Serial number:   14237388

Voir aussi

$ opensc-tool --atr 
Using reader with a card: Yubico YubiKey OTP+FIDO+CCID 00 00
3b:fd:13:00:00:81:31:fe:15:80:73:c0:21:c0:57:59:75:62:69:4b:65:79:40
$ opensc-tool -a -v
Using reader with a card: Yubico YubiKey OTP+FIDO+CCID 00 00
Card ATR:
3B FD 13 00 00 81 31 FE 15 80 73 C0 21 C0 57 59 ;.....1...s.!.WY
75 62 69 4B 65 79 40                            ubiKey@

Exemple

La commande ci dessous ne fonctionne pas, ce n'est pas la bonne clef

$ gpg ~/tmp/plop.txt.gpg 
Please insert the card with serial number: 0005 0000BD62

Mais où est donc (ornicar ?) l'id 0000BD62 ?

$ rgrep 0000BD62 ~/.gnupg
~/.gnupg/private-keys-v1.d/F66AA9329AEA6F09D69DD852BF8233DE68119AF5.key:Token: D27600012401030400050000BD620000 OPENPGP.3 - 0005+0000BD62
~/.gnupg/private-keys-v1.d/F66AA9329AEA6F09D69DD852BF8233DE68119AF5.key:  (#D27600012401030400050000BD620000# OPENPGP.3))))
~/.gnupg/private-keys-v1.d/3F5417680639FCEF05C54803B408B83BA496E964.key:Token: D27600012401030400050000BD620000 OPENPGP.1 - 0005+0000BD62
~/.gnupg/private-keys-v1.d/3F5417680639FCEF05C54803B408B83BA496E964.key:  (#D27600012401030400050000BD620000# OPENPGP.1))))
~/.gnupg/private-keys-v1.d/DC81057888D07B12268226B9F136013C4D32566D.key:Token: D27600012401030400050000BD620000 OPENPGP.2 - 0005+0000BD62
~/.gnupg/private-keys-v1.d/DC81057888D07B12268226B9F136013C4D32566D.key:  (#D27600012401030400050000BD620000# OPENPGP.2))))

Trouver l'id la clef actuelle

$ gpg --card-status | grep "^Application ID"
Application ID ...: D2760001240103040006142373880000

On remplace l'ancien id par le nouveau

cp -a ~/.gnupg ~/.gnupg.bak
sed -i -e 's/D27600012401030400050000BD620000/D2760001240103040006142373880000/g' ~/.gnupg/private-keys-v1.d/*.key

Ça fonctionne

gpg ~/tmp/plop.txt.gpg

Autre

Python et carte GPG

Export / Import FIXME

python3 -m gpgcard.gpgcli --backup --pinpad --backup-keys --file gpg-key.pickle
 
python3 -m gpgcard.gpgcli --restore --pinpad --file gpg-key.pickle
2025/03/24 15:06

Gostcrypt

Voir :

Voir aussi :

  • VeraCrypt (anciennement TrueCrypt)
  • Cryptsetup - luks
  • wipefs

Installation

wget "https://www.gostcrypt.org/download/1.0/linux/Gostcrypt_1.0.deb"
sha256sum Gostcrypt_1.0.deb
dpkg -i Gostcrypt_1.0.deb
apt-get -f install

config du sudoers Normalement pas nécessaire, sauf pour disque ou partition entière Attention a ne pas autoriser n'importe qui !\ Car droit de détruire le système de fichier

visudo -f /etc/sudoers.d/gostcrypt

/etc/sudoers.d/gostcrypt

jean       ALL=(root) NOPASSWD: /usr/bin/gostcrypt

Test

gostcrypt --test

Pour une utilisation en ligne de commande sans sortie sur le serveur X

unset DISPLAY

Création d'un clef

gostcrypt --create-keyfile key < /dev/urandom

Pour l'aide

gostcrypt -t --help | less

Création d'un volume en ligne de commande (mode fichier)

gostcrypt -t -k key -c disk --encryption="GOST 28147-89" --hash="GOST R 34.11-2012" -password="" --volume-type=normal --random-source=/dev/urandom --filesystem=none --size=$((100 * 1024 * 1024))

Création d'un volume en ligne de commande (mode disque / partition)

gostcrypt -t -k /home/jean/key -c /dev/sdg --encryption="GOST 28147-89" --hash="GOST R 34.11-2012" -password="" --volume-type=normal --random-source=/dev/urandom --filesystem=none
sudo gostcrypt -t --filesystem=none --protect-hidden=no -password="" -k /home/jean/key /dev/sdb
$ gostcrypt -t -l
1: /home/jean/disk /dev/loop0 -

Vérifions que la taille correspond bien à notre nouveau volume chiffré

fdisk -l /dev/loop0

Formatons !

mkfs.ext4 /dev/loop0

On monte la partition

mount -o noatime /dev/loop0 /mnt/gostcrypt/
df -hP /mnt/gostcrypt/

Quand on a fini

umount /mnt/gostcrypt 
gostcrypt -t -d

Bug

Error: No such file or directory

Solution : Prendre l'ancienne version gostcrypt_debian_7.4_amd64

Liens :

Accroire la sécurité en utilisant plusieurs clefs

La taille fixe de clef, limité à 64 octets n'est pas une limite.

Ici nous allons utiliser un gros fichier (monfichierclef) que nous allons chiffrer avec une petite sous-clef (k1.txt). Tout cela pour créer une nouvelle clef (k2)

cat monfichierclef | openssl enc -bf -S abcd -out k2 -pass file:k1.txt

L'option -S, c'est le sel (salt), ici abcd. Il doit être en hexadécimal. \ Sans cela la commande openssl, créerai à chaque fois un fichier k2 différant

Les clefs doivent obligatoirement faire une taille de 64 octets, découpons k2 en plusieurs petites clefs

mkdir plop
cd plop
split -b 64 ../k2

Nous effaçons le seul fichier qui ne fait pas exactement 64 octets, c'est à dire le dernier généré (tronqué)

find ../plop -not -size 64c -delete

Voilà comment utiliser toutes les clefs pour créer un volume

gostcrypt -t -k $(echo *| tr " " ",") -c ../disk --encryption="GOST 28147-89" --hash="GOST R 34.11-2012" -password="" --volume-type=normal --random-source=/dev/urandom --filesystem=none --size=$((100 * 1024 * 1024)

Pb install

wget https://www.gostcrypt.org/download/1.0/linux/Gostcrypt_1.0.deb
dpkg -i Gostcrypt_1.0.deb
# apt-get -f install
Unpacking libgl1-mesa-dri:amd64 (from .../libgl1-mesa-dri_8.0.5-4+deb7u2_amd64.deb) ...
dpkg: error processing /var/cache/apt/archives/libgl1-mesa-dri_8.0.5-4+deb7u2_amd64.deb (--unpack):
 trying to overwrite shared '/etc/drirc', which is different from other instances of package libgl1-mesa-dri:amd64
Processing triggers for man-db ...
Errors were encountered while processing:
 /var/cache/apt/archives/libgl1-mesa-dri_8.0.5-4+deb7u2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Si erreur, relancer la commande :

apt-get -f install
2025/03/24 15:06

Notes GostCrypt package deb

Voir :

GostCrypt_1.3 sur Debian Wheezy

Ouverture du paquage Debian

wget http://www.gostcrypt.org/download/1.3/Linux/Deb/GostCrypt_1.3_Debian.x86_64.deb
mkdir ~/GostCrypt_1.3_Debian_Wheezy
cd ~/GostCrypt_1.3_Debian_Wheezy/
ar x ../GostCrypt_1.3_Debian.x86_64.deb
tar --same-owner xvf data.tar.xz
mkdir DEBIAN
cd DEBIAN
tar xvf ../control.tar.gz
rm control.tar.gz  data.tar.xz  debian-binary

Compilation

https://www.gostcrypt.org/wiki/doku.php?id=compilation_installation:compilation:linux:ubuntu

Install des dépendances

sudo apt-get install libfuse-dev libwxgtk2.8-dev pkg-config
wget http://www.gostcrypt.org/download/1.3/Linux/Sources/GostCrypt_1.3_Linux.tar.gz
tar xvf GostCrypt_1.3_Linux.tar.gz
 
make NOGUI=1

L'éxecutable est ici : \ ./Main/gostcrypt.cli

Modification du paquage

rm -f ~/GostCrypt_1.3_Debian_Wheezy/usr/bin/gostcrypt.cli ~/GostCrypt_1.3_Debian_Wheezy/usr/bin/gostcrypt
cp -p Main/gostcrypt.cli ~/GostCrypt_1.3_Debian_Wheezy/usr/bin
cd  ~/GostCrypt_1.3_Debian_Wheezy
rm -rf usr/share/applications/ usr/share/Gostcrypt/
$ cat DEBIAN/control
- Depends: libc6, libfuse2, libgcc1, libstdc++6, libwxbase3.0-dev , libwxgtk3.0-dev
+ Depends: libc6, libfuse2, libgcc1, libstdc++6, libwxbase2.8-dev
- Version: 1.3
+ Version: 1.3~Jb
cd /usr/bin
ln -s gostcrypt.cli gostcrypt

Reconstruction du paquet

cd ~/GostCrypt_1.3_Debian_Wheezy
md5sum $(find . -not -wholename "./DEBIAN/*" -type f -not -name "debian-binary" )> DEBIAN/md5sums
cd ~
dpkg-deb --build GostCrypt_1.3_Debian_Wheezy

Installation

dpkg -i GostCrypt_1.3_Debian_Wheezy.deb

FIXME

2025/03/24 15:06

AWS Réseau

Note en vrac

aws create-dhcp-options --dhcp-configurations ntp-servers

create-dhcp-options
associate-dhcp-options 
describe-dhcp-options 

ntp-servers


                {
                    "Key": "ntp-servers",
                    "Values": [
                        {
                            "Value": "169.254.169.123"
                        }
                    ]

					
-----
aws ec2 create-dhcp-options --dhcp-configurations Key=domain-name,Values=plop.aws Key=domain-name-servers,Values=AmazonProvidedDNS Key=ntp-servers,Values=10.240.98.16

FIXME

2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki