@@ -2402,6 +2402,15 @@ EVPKeyPointer::operator Rsa() const {
2402
2402
return Rsa (rsa);
2403
2403
}
2404
2404
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
+
2405
2414
bool EVPKeyPointer::validateDsaParameters () const {
2406
2415
if (!pkey_) return false ;
2407
2416
/* Validate DSA2 parameters from FIPS 186-4 */
@@ -2660,8 +2669,8 @@ bool SSLCtxPointer::setGroups(const char* groups) {
2660
2669
2661
2670
// ============================================================================
2662
2671
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 () ));
2665
2674
}
2666
2675
2667
2676
const Cipher Cipher::FromNid (int nid) {
@@ -2748,6 +2757,10 @@ bool Cipher::isSupportedAuthenticatedMode() const {
2748
2757
}
2749
2758
}
2750
2759
2760
+ bool Cipher::IsValidGCMTagLength (unsigned int tag_len) {
2761
+ return tag_len == 4 || tag_len == 8 || (tag_len >= 12 && tag_len <= 16 );
2762
+ }
2763
+
2751
2764
// ============================================================================
2752
2765
2753
2766
CipherCtxPointer CipherCtxPointer::New () {
@@ -3902,4 +3915,34 @@ std::pair<std::string, std::string> X509Name::Iterator::operator*() const {
3902
3915
std::string (reinterpret_cast <const char *>(value_str), value_str_size)};
3903
3916
}
3904
3917
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
+
3905
3948
} // namespace ncrypto
0 commit comments