Copying RSAKey


#1

RSAKey class does not have operator= implemented nor the copy constructor. BlowFish, on the other hand, has… Is there a reson for this, or simply they are not there because no-one ever needed them?


#2

I’d expect the compiler to generate its copy constructor and operator= method… Isn’t that working?


#3

Haven’t tried honestly ^_^… I will soon


#4

I get no compilation errors so it seems that the compiler provides them correctly.
However, I noticed that RSAKey uses BigInteger to store the two parts, which in turn uses HeapBlock to store its internal data… is it safe to let the compiler make a shallow copy of all of this structure, rather than explicitly making a deep copy of that?


#5

BigInteger has a full set of copy and assignment operators, the compiler won’t do a shallow copy!


#6

Ah I had to re-read some books because on the internet I could not find any clear information regarding how the default copy constructor and operator= operate on non primitive members… now all is clear, you are right, there is no need for them in RSAKey


#7

what about an operator== and operator!= for comparisons, though?


#8

Good suggestion, I’ll add those!