3 lá˜_«ã@s„ddlmZmZmZddlmZddlmZddlm Z ddl m Z m Z dZ eje ƒGdd„deƒƒZeje ƒGd d „d eƒƒZd S) é)Úabsolute_importÚdivisionÚprint_function)Úutils)Ú_evp_pkey_derive)Ú serialization)ÚX448PrivateKeyÚ X448PublicKeyé8c@s$eZdZdd„Zdd„Zdd„ZdS)Ú_X448PublicKeycCs||_||_dS)N)Ú_backendÚ _evp_pkey)ÚselfÚbackendÚevp_pkey©rú/usr/lib64/python3.6/x448.pyÚ__init__sz_X448PublicKey.__init__cCsV|tjjks|tjjkr@|tjjk s0|tjjk r8tdƒ‚|jƒS|jj||||jdƒS)Nz3When using Raw both encoding and format must be Raw) rÚEncodingÚRawÚ PublicFormatÚ ValueErrorÚ_raw_public_bytesr Z_public_key_bytesr )rÚencodingÚformatrrrÚ public_bytess    z_X448PublicKey.public_bytescCsp|jjjdtƒ}|jjjdtƒ}|jjj|j||ƒ}|jj|dkƒ|jj|dtkƒ|jjj|tƒdd…S)Nzunsigned char []zsize_t *ér) r Ú_ffiÚnewÚ_X448_KEY_SIZEÚ_libÚEVP_PKEY_get_raw_public_keyr Úopenssl_assertÚbuffer)rÚbufÚbuflenÚresrrrr+s z _X448PublicKey._raw_public_bytesN)Ú__name__Ú __module__Ú __qualname__rrrrrrrr sr c@s4eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd S) Ú_X448PrivateKeycCs||_||_dS)N)r r )rrrrrrr8sz_X448PrivateKey.__init__cCsd|jjjdtƒ}|jjjdtƒ}|jjj|j||ƒ}|jj|dkƒ|jj|dtkƒ|jj|ƒS)Nzunsigned char []zsize_t *rr) r rrrr r!r r"Zx448_load_public_bytes)rr$r%r&rrrÚ public_key<s z_X448PrivateKey.public_keycCs"t|tƒstdƒ‚t|j|j|ƒS)Nz&peer_public_key must be X448PublicKey.)Ú isinstancer Ú TypeErrorrr r )rZpeer_public_keyrrrÚexchangeFs z_X448PrivateKey.exchangecCsf|tjjks|tjjkrN|tjjk s>|tjjk s>t|tjƒ rFtdƒ‚|jƒS|j j |||||j dƒS)NzcWhen using Raw both encoding and format must be Raw and encryption_algorithm must be NoEncryption()) rrrrZ PrivateFormatr,Z NoEncryptionrÚ_raw_private_bytesr Z_private_key_bytesr )rrrZencryption_algorithmrrrÚ private_bytesLs     z_X448PrivateKey.private_bytescCsp|jjjdtƒ}|jjjdtƒ}|jjj|j||ƒ}|jj|dkƒ|jj|dtkƒ|jjj|tƒdd…S)Nzunsigned char []zsize_t *rr) r rrrr ZEVP_PKEY_get_raw_private_keyr r"r#)rr$r%r&rrrr/cs z"_X448PrivateKey._raw_private_bytesN)r'r(r)rr+r.r0r/rrrrr*6s  r*N)Z __future__rrrZ cryptographyrZ*cryptography.hazmat.backends.openssl.utilsrZcryptography.hazmat.primitivesrZ.cryptography.hazmat.primitives.asymmetric.x448rr rZregister_interfaceÚobjectr r*rrrrÚs   #