src/Keeg.Crypto/Encryption/SymmetricAlgorithm.cs
/// <summary>
/// Takes a bit length input and returns whether that length is a valid size according to <see cref="LegalKeySizes"/>
/// </summary>
/// <param name="bitLength">Size of the key in bits.</param>
/// <returns>True if the given bit length is valid.</returns>
Takes a bit length input and returns whether that length is a valid size according to
Takes a bit length input and returns whether that length is a valid size according to
public bool ValidKeySize(int bitLength)
        {
            if (m_legalKeySizes == null)
            {
                return false;
            }
            for (int i = 0; i < m_legalKeySizes.Length; i++)
            {
                if (m_legalKeySizes[i].SkipSize == 0)
                {
                    if (m_legalKeySizes[i].MinSize == bitLength) 
                    {
                        return true;
                    }
                }
                else
                {
                    for (int j = m_legalKeySizes[i].MinSize; j <= m_legalKeySizes[i].MaxSize; 
                        j += m_legalKeySizes[i].SkipSize)
                    {
                        if (j == bitLength)
                        {
                            return true;
                        }
                    }
                }
            }
            return false;
        }
public bool ValidKeySize ( int bitLength ) { if ( m_legalKeySizes == null ) { return false ; } for ( int i = 0 ; i < m_legalKeySizes . Length ; i ++ ) { if ( m_legalKeySizes [ i ] . SkipSize == 0 ) { if ( m_legalKeySizes [ i ] . MinSize == bitLength ) { return true ; } } else { for ( int j = m_legalKeySizes [ i ] . MinSize ; j <= m_legalKeySizes [ i ] . MaxSize ; j += m_legalKeySizes [ i ] . SkipSize ) { if ( j == bitLength ) { return true ; } } } } return false ; }
Takes a bit length input and returns whether that length is a valid size according to
Takes a bit length input and returns whether that length is a valid size according to
// If a cipher has only one valid key size, MinSize == MaxSize and SkipSize will be 0 // MinSize = MaxSize
True if the given bit length is valid.
True if the given bit length is valid .
bitLength
int
Size of the key in bits.
Size of the key in bits .