xboxkrnl: Add a bunch of crypto functions
This commit is contained in:
34
third_party/crypto/des/descbc.h
vendored
Normal file
34
third_party/crypto/des/descbc.h
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef DESCBC_H
|
||||
#define DESCBC_H
|
||||
|
||||
#include "des.h"
|
||||
|
||||
class DESCBC
|
||||
{
|
||||
public:
|
||||
DESCBC(ui64 key, ui64 iv) : des(key), iv(iv), last_block(iv) {}
|
||||
inline ui64 encrypt(ui64 block)
|
||||
{
|
||||
last_block = des.encrypt(block ^ last_block);
|
||||
return last_block;
|
||||
}
|
||||
|
||||
inline ui64 decrypt(ui64 block)
|
||||
{
|
||||
ui64 result = des.decrypt(block) ^ last_block;
|
||||
last_block = block;
|
||||
return result;
|
||||
}
|
||||
|
||||
inline void reset()
|
||||
{
|
||||
last_block = iv;
|
||||
}
|
||||
|
||||
private:
|
||||
DES des;
|
||||
ui64 iv;
|
||||
ui64 last_block;
|
||||
};
|
||||
|
||||
#endif // DESCBC_H
|
||||
Reference in New Issue
Block a user