2016-05-17 18:52:22 +00:00
|
|
|
/*
|
|
|
|
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
2015-01-22 03:40:55 +00:00
|
|
|
*
|
2018-12-06 12:19:23 +00:00
|
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-05-17 18:52:22 +00:00
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
1998-12-21 10:52:47 +00:00
|
|
|
*/
|
|
|
|
|
1999-04-23 22:13:45 +00:00
|
|
|
#include <openssl/blowfish.h>
|
1998-12-21 10:52:47 +00:00
|
|
|
#include "bf_locl.h"
|
1999-04-23 22:13:45 +00:00
|
|
|
#include <openssl/opensslv.h>
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
/*
|
|
|
|
* Blowfish as implemented from 'Blowfish: Springer-Verlag paper' (From
|
|
|
|
* LECTURE NOTES IN COMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION, CAMBRIDGE
|
|
|
|
* SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993)
|
1998-12-21 10:52:47 +00:00
|
|
|
*/
|
|
|
|
|
1999-04-19 21:31:43 +00:00
|
|
|
const char *BF_options(void)
|
2015-01-22 03:40:55 +00:00
|
|
|
{
|
2017-10-17 14:04:09 +00:00
|
|
|
return "blowfish(ptr)";
|
2015-01-22 03:40:55 +00:00
|
|
|
}
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2000-02-08 14:19:14 +00:00
|
|
|
void BF_ecb_encrypt(const unsigned char *in, unsigned char *out,
|
2015-01-22 03:40:55 +00:00
|
|
|
const BF_KEY *key, int encrypt)
|
|
|
|
{
|
|
|
|
BF_LONG l, d[2];
|
1998-12-21 10:52:47 +00:00
|
|
|
|
2015-01-22 03:40:55 +00:00
|
|
|
n2l(in, l);
|
|
|
|
d[0] = l;
|
|
|
|
n2l(in, l);
|
|
|
|
d[1] = l;
|
|
|
|
if (encrypt)
|
|
|
|
BF_encrypt(d, key);
|
|
|
|
else
|
|
|
|
BF_decrypt(d, key);
|
|
|
|
l = d[0];
|
|
|
|
l2n(l, out);
|
|
|
|
l = d[1];
|
|
|
|
l2n(l, out);
|
|
|
|
l = d[0] = d[1] = 0;
|
|
|
|
}
|