@@ -2402,6 +2402,15 @@ EVPKeyPointer::operator Rsa() const {
24022402 return Rsa (rsa);
24032403}
24042404
2405+ EVPKeyPointer::operator Dsa () const {
2406+ int type = id ();
2407+ if (type != EVP_PKEY_DSA) return {};
2408+
2409+ OSSL3_CONST DSA* dsa = EVP_PKEY_get0_DSA (get ());
2410+ if (dsa == nullptr ) return {};
2411+ return Dsa (dsa);
2412+ }
2413+
24052414bool EVPKeyPointer::validateDsaParameters () const {
24062415 if (!pkey_) return false ;
24072416 /* Validate DSA2 parameters from FIPS 186-4 */
@@ -2660,8 +2669,8 @@ bool SSLCtxPointer::setGroups(const char* groups) {
26602669
26612670// ============================================================================
26622671
2663- const Cipher Cipher::FromName (const char * name) {
2664- return Cipher (EVP_get_cipherbyname (name));
2672+ const Cipher Cipher::FromName (std::string_view name) {
2673+ return Cipher (EVP_get_cipherbyname (name. data () ));
26652674}
26662675
26672676const Cipher Cipher::FromNid (int nid) {
@@ -2748,6 +2757,10 @@ bool Cipher::isSupportedAuthenticatedMode() const {
27482757 }
27492758}
27502759
2760+ bool Cipher::IsValidGCMTagLength (unsigned int tag_len) {
2761+ return tag_len == 4 || tag_len == 8 || (tag_len >= 12 && tag_len <= 16 );
2762+ }
2763+
27512764// ============================================================================
27522765
27532766CipherCtxPointer CipherCtxPointer::New () {
@@ -3902,4 +3915,34 @@ std::pair<std::string, std::string> X509Name::Iterator::operator*() const {
39023915 std::string (reinterpret_cast <const char *>(value_str), value_str_size)};
39033916}
39043917
3918+ // ============================================================================
3919+
3920+ Dsa::Dsa () : dsa_ (nullptr ) {}
3921+
3922+ Dsa::Dsa (OSSL3_CONST DSA* dsa) : dsa_ (dsa) {}
3923+
3924+ const BIGNUM* Dsa::getP () const {
3925+ if (dsa_ == nullptr ) return nullptr ;
3926+ const BIGNUM* p;
3927+ DSA_get0_pqg (dsa_, &p, nullptr , nullptr );
3928+ return p;
3929+ }
3930+
3931+ const BIGNUM* Dsa::getQ () const {
3932+ if (dsa_ == nullptr ) return nullptr ;
3933+ const BIGNUM* q;
3934+ DSA_get0_pqg (dsa_, nullptr , &q, nullptr );
3935+ return q;
3936+ }
3937+
3938+ size_t Dsa::getModulusLength () const {
3939+ if (dsa_ == nullptr ) return 0 ;
3940+ return BignumPointer::GetBitCount (getP ());
3941+ }
3942+
3943+ size_t Dsa::getDivisorLength () const {
3944+ if (dsa_ == nullptr ) return 0 ;
3945+ return BignumPointer::GetBitCount (getQ ());
3946+ }
3947+
39053948} // namespace ncrypto
0 commit comments