[python] M2Crypto를 사용하여 DSA 디지털 서명을 생성하는 방법은 어떻게 되나요?
from M2Crypto import DSA, BIO
# DSA 파라미터 생성
dsa = DSA.gen_params(1024)
# DSA 키페어 생성
dsa.gen_key()
# 메시지 서명
message = b'Hello, World!'
signature = dsa.sign_asn1(message)
# 서명 검증
if dsa.verify_asn1(message, signature):
print("서명이 유효합니다.")
else:
print("서명이 유효하지 않습니다.")
위 코드는 M2Crypto 라이브러리를 사용하여 DSA 디지털 서명을 생성하고 검증하는 방법을 보여줍니다. 먼저 DSA 파라미터와 키페어를 생성하고, 메시지에 대한 서명을 생성하고 검증합니다.
참고 문헌:
- M2Crypto: https://gitlab.com/m2crypto/m2crypto