Last active
February 3, 2022 05:49
-
-
Save why-not/856ada1afaed6f097c4e4617c1af9237 to your computer and use it in GitHub Desktop.
Sign and Verify Using Public/Private Keys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# generate private key | |
openssl genrsa -out private_key.pem 4096 | |
# extract public key | |
openssl rsa -in private_key.pem -pubout > public_key.pub | |
# sign using private key | |
openssl dgst -sign private_key.pem -keyform PEM -sha256 -out VGG_ILSVRC_16_layers.caffemodel.sign -binary VGG_ILSVRC_16_layers.caffemodel | |
# extract using public key | |
openssl dgst -verify public_key.pub -keyform PEM -sha256 -signature VGG_ILSVRC_16_layers.caffemodel.sign -binary VGG_ILSVRC_16_layers.caffemodel | |
# tamper with the model | |
echo "Tamper" >> VGG_ILSVRC_16_layers.caffemodel.tamper | |
# verify tampered file | |
openssl dgst -verify public_key.pub -keyform PEM -sha256 -signature VGG_ILSVRC_16_layers.caffemodel.sign -binary VGG_ILSVRC_16_layers.caffemodel.tamper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment