With a structure, you can just do a memory copy.
Be aware that both structures must have the same layout.
memcpy(&cd->ks1, &ks1, sizeof(cd->ks1));
memcpy(&cd->ks2, &ks2, sizeof(cd->ks2));
If you're not happy with the memcpy, you can do something slightly more complicated.
typedef struct DES_ks
{
union
{
DES_cblock cblock;
DES_LONG deslong[2];
} ks[16];
public:
const DES_ks & operator = (const DES_ks & rhs);
public:
DES_ks(void) { }
DES_ks(const DES_ks & rhs);
} DES_key_schedule;
inline const DES_ks & DES_ks::operator = (const DES_ks & rhs)
{
for (size_t Index = 0; Index < (sizeof(ks) / sizeof(ks[0])); Index++)
{
ks[Index].deslong[0] = rhs.ks[Index].deslong[0];
ks[Index].deslong[1] = rhs.ks[Index].deslong[1];
}
return *this;
}
inline DES_ks::DES_ks(const DES_ks & rhs)
{
*this = rhs;
}
With the operator overloading you can use:
cd->ks1 = ks1;
cd->ks2 = ks2;