嵌入式开发基础
实验一 嵌入式开发基础
1-3 学时实践要求(30 分)
- 参考云班课相关教学视频,在 Ubuntu或openEuler中(推荐 openEuler)中实践课程思维导图中OpenSSL相关内容,使用Markdown记录详细记录实践过程,每完成一项git commit 一次。(5分)
openssl cmd
tongshijia@Sodom:~/test1$ openssl version
OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)
openssl list -help
tongshijia@Sodom:~/test1$ openssl list -help
Usage: list [options]
General options:
-help Display this summary
Output options:
-1 List in one column
-verbose Verbose listing
-select val Select a single algorithm
-commands List of standard commands
-standard-commands List of standard commands
-digest-commands List of message digest commands (deprecated)
-digest-algorithms List of message digest algorithms
-kdf-algorithms List of key derivation and pseudo random function algorithms
-random-instances List the primary, public and private random number generator details
-random-generators List of random number generators
-mac-algorithms List of message authentication code algorithms
-cipher-commands List of cipher commands (deprecated)
-cipher-algorithms List of cipher algorithms
-encoders List of encoding methods
-decoders List of decoding methods
-key-managers List of key managers
-key-exchange-algorithms List of key exchange algorithms
-kem-algorithms List of key encapsulation mechanism algorithms
-signature-algorithms List of signature algorithms
-asymcipher-algorithms List of asymmetric cipher algorithms
-public-key-algorithms List of public key algorithms
-public-key-methods List of public key methods
-store-loaders List of store loaders
-providers List of provider information
-engines List of loaded engines
-disabled List of disabled features
-options val List options for specified command
-objects List built in objects (OID<->name mappings)
Provider options:
-provider-path val Provider load path (must be before 'provider' argument if required)
-provider val Provider to load (can be specified multiple times)
-propquery val Property query used when fetching algorithms
openssl <==>openssl help
tongshijia@Sodom:~/test1$ openssl -help
help:
Standard commands
asn1parse ca ciphers cmp
cms crl crl2pkcs7 dgst
dhparam dsa dsaparam ec
ecparam enc engine errstr
fipsinstall gendsa genpkey genrsa
help info kdf list
mac nseq ocsp passwd
pkcs12 pkcs7 pkcs8 pkey
pkeyparam pkeyutl prime rand
rehash req rsa rsautl
s_client s_server s_time sess_id
smime speed spkac srp
storeutl ts verify version
x509
Message Digest commands (see the `dgst' command for more details)
blake2b512 blake2s256 md4 md5
rmd160 sha1 sha224 sha256
sha3-224 sha3-256 sha3-384 sha3-512
sha384 sha512 sha512-224 sha512-256
shake128 shake256 sm3
Cipher commands (see the `enc' command for more details)
aes-128-cbc aes-128-ecb aes-192-cbc aes-192-ecb
aes-256-cbc aes-256-ecb aria-128-cbc aria-128-cfb
aria-128-cfb1 aria-128-cfb8 aria-128-ctr aria-128-ecb
aria-128-ofb aria-192-cbc aria-192-cfb aria-192-cfb1
aria-192-cfb8 aria-192-ctr aria-192-ecb aria-192-ofb
aria-256-cbc aria-256-cfb aria-256-cfb1 aria-256-cfb8
aria-256-ctr aria-256-ecb aria-256-ofb base64
bf bf-cbc bf-cfb bf-ecb
bf-ofb camellia-128-cbc camellia-128-ecb camellia-192-cbc
camellia-192-ecb camellia-256-cbc camellia-256-ecb cast
cast-cbc cast5-cbc cast5-cfb cast5-ecb
cast5-ofb des des-cbc des-cfb
des-ecb des-ede des-ede-cbc des-ede-cfb
des-ede-ofb des-ede3 des-ede3-cbc des-ede3-cfb
des-ede3-ofb des-ofb des3 desx
rc2 rc2-40-cbc rc2-64-cbc rc2-cbc
rc2-cfb rc2-ecb rc2-ofb rc4
rc4-40 seed seed-cbc seed-cfb
seed-ecb seed-ofb sm4-cbc sm4-cfb
sm4-ctr sm4-ecb sm4-ofb
####数据输入输出 文本
tongshijia@Sodom:~/test1$ echo 123 | openssl sm3
SM3(stdin)= e95001aed4b6f7de59169913997dace404f05091ed49c37133a9950a69405a9c
tongshijia@Sodom:~/test1$ echo "123" | openssl sm3
SM3(stdin)= e95001aed4b6f7de59169913997dace404f05091ed49c37133a9950a69405a9c
tongshijia@Sodom:~/test1$ echo 123 | od -tx1 -tc
0000000 31 32 33 0a
1 2 3 \n
0000004
tongshijia@Sodom:~/test1$ echo -n 123 | od -tx1 -tc
0000000 31 32 33
1 2 3
0000003
tongshijia@Sodom:~/test1$ echo 123 | openssl sm3
SM3(stdin)= e95001aed4b6f7de59169913997dace404f05091ed49c37133a9950a69405a9c
tongshijia@Sodom:~/test1$ echo -n 123 | openssl sm3
SM3(stdin)= 6e0f9e14344c5406a0cf5a3b4dfb665f87f4a771a31f7edbb5c72874a32b2957
tongshijia@Sodom:~/test1$ echo 123 > 123.txt
tongshijia@Sodom:~/test1$ openssl sm3 -file 123.txt
SM3(123.txt)= e95001aed4b6f7de59169913997dace404f05091ed49c37133a9950a69405a9c
tongshijia@Sodom:~/test1$ echo 123 | openssl sm3
SM3(stdin)= e95001aed4b6f7de59169913997dace404f05091ed49c37133a9950a69405a9c
####数据输入输出 二进制
tongshijia@Sodom:~/test1$ echo "obase=16;123" | bc
7B
tongshijia@Sodom:~/test1$ echo -n -e "\x7B" > 123.bin
tongshijia@Sodom:~/test1$ od -tx1 123.bin
0000000 7b
0000001
tongshijia@Sodom:~/test1$ openssl sm3 -file 123.bin
SM3(123.bin)= 2ed59fea0dbe4e4f02de67ee657eb6be8e22a7db425103402d8a36d7b6f6d344
tongshijia@Sodom:~/test1$ echo -ne "\x7B" | openssl sm3
SM3(stdin)= 2ed59fea0dbe4e4f02de67ee657eb6be8e22a7db425103402d8a36d7b6f6d344
####常用命令 prime
tongshijia@Sodom:~/test1$ openssl prime -help
Usage: prime [options] [number...]
General options:
-help Display this summary
-bits +int Size of number in bits
-checks +int Number of checks
Output options:
-hex Hex output
-generate Generate a prime
-safe When used with -generate, generate a safe prime
Provider options:
-provider-path val Provider load path (must be before 'provider' argument if required)
-provider val Provider to load (can be specified multiple times)
-propquery val Property query used when fetching algorithms
Parameters:
number Number(s) to check for primality if not generating
####素性检查
tongshijia@Sodom:~/test1$ openssl prime 3
3 (3) is prime
tongshijia@Sodom:~/test1$ openssl prime 33
21 (33) is not prime
tongshijia@Sodom:~/test1$ openssl prime -checks 10 33
21 (33) is not prime
tongshijia@Sodom:~/test1$ openssl prime -hex 4F
4F (4F) is prime
####素数产生
tongshijia@Sodom:~/test1$ openssl prime -generate -bits 10
773
tongshijia@Sodom:~/test1$ openssl prime 773
305 (773) is prime
tongshijia@Sodom:~/test1$ openssl prime -generate -bits 10
787
tongshijia@Sodom:~/test1$ openssl prime 787
313 (787) is prime
tongshijia@Sodom:~/test1$ openssl prime -generate -bits 10 -hex
03F5
tongshijia@Sodom:~/test1$ openssl prime -hex 03F5
3F5 (03F5) is prime