Hi all

I have recently change compiler, from gcc(libstdc++) to clang(libc++) on
iOS. After the change the generation of key, using the following snib, never
terminates.
...
CryptoPP::RSAES< CryptoPP::OAEP <CryptoPP::SHA1> >::PrivateKey
privateSessionKey;
CryptoPP::AutoSeededX917RNG<CryptoPP::AES> rng;
privateSessionKey.GenerateRandomWithKeySize(rng, 2048);
...

I haunted it dow to be related to the use of vector<bool> in
nbtheory.cpp(line 310) which seems to give unexpected values when using the
clang(and libc++).
..
308 bool PrimeSieve::NextCandidate(Integer &c) 
309 {
310      bool safe = SafeConvert(std::find(m_sieve.begin()+m_next,
m_sieve.end(), false) - m_sieve.begin(), m_next);
311        assert(safe);
312      if (m_next == m_sieve.size())
..

I isolated the issue to the following example:
std::vector<bool> my_vector;
my_vector.push_back(true);
my_vector.push_back(false);
my_vector.push_back(true);
my_vector.push_back(true);
my_vector.push_back(true);
my_vector.push_back(false);
my_vector.push_back(true);
long idx = std::find(my_vector.begin()+2, my_vector.end(), false) -
my_vector.begin();
std::cout << "idx:" << idx << std::endl;

which returns
idx:0
when using clang (and libc++) and
idx:5
when using gcc (and libstdc++) as expected.

Can anybody confirm this issue?

Does anybody know if vector<bool> is used extensive in Crypto++ ?

regards - thwang

-- 
View this message in context: 
http://old.nabble.com/keygeneration-on-ios-using-clang%28libc%2B%2B%29-never-terminates-tp34614981p34614981.html
Sent from the Crypto++ Users mailing list archive at Nabble.com.

-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.

Reply via email to