Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
a965875a
Commit
a965875a
authored
Apr 19, 2006
by
msvensson@shellback.(none)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Import from upstream yaSSL
parent
0d1bd3b1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
58 deletions
+55
-58
extra/yassl/src/template_instnt.cpp
extra/yassl/src/template_instnt.cpp
+2
-0
extra/yassl/taocrypt/include/misc.hpp
extra/yassl/taocrypt/include/misc.hpp
+1
-1
extra/yassl/taocrypt/src/template_instnt.cpp
extra/yassl/taocrypt/src/template_instnt.cpp
+1
-0
extra/yassl/taocrypt/test/test.cpp
extra/yassl/taocrypt/test/test.cpp
+51
-57
No files found.
extra/yassl/src/template_instnt.cpp
View file @
a965875a
...
@@ -87,6 +87,8 @@ template void ysDelete<BulkCipher>(BulkCipher*);
...
@@ -87,6 +87,8 @@ template void ysDelete<BulkCipher>(BulkCipher*);
template
void
ysDelete
<
Digest
>(
Digest
*
);
template
void
ysDelete
<
Digest
>(
Digest
*
);
template
void
ysDelete
<
X509
>(
X509
*
);
template
void
ysDelete
<
X509
>(
X509
*
);
template
void
ysDelete
<
Message
>(
Message
*
);
template
void
ysDelete
<
Message
>(
Message
*
);
template
void
ysDelete
<
sslFactory
>(
sslFactory
*
);
template
void
ysDelete
<
Sessions
>(
Sessions
*
);
template
void
ysArrayDelete
<
unsigned
char
>(
unsigned
char
*
);
template
void
ysArrayDelete
<
unsigned
char
>(
unsigned
char
*
);
template
void
ysArrayDelete
<
char
>(
char
*
);
template
void
ysArrayDelete
<
char
>(
char
*
);
}
}
...
...
extra/yassl/taocrypt/include/misc.hpp
View file @
a965875a
...
@@ -81,7 +81,7 @@ void CleanUp();
...
@@ -81,7 +81,7 @@ void CleanUp();
::
operator
delete
[](
ptr
,
TaoCrypt
::
tc
);
::
operator
delete
[](
ptr
,
TaoCrypt
::
tc
);
}
}
#define NEW_TC new (tc)
#define NEW_TC new (
TaoCrypt::
tc)
// to resolve compiler generated operator delete on base classes with
// to resolve compiler generated operator delete on base classes with
...
...
extra/yassl/taocrypt/src/template_instnt.cpp
View file @
a965875a
...
@@ -46,6 +46,7 @@ template class RSA_Decryptor<RSA_BlockType2>;
...
@@ -46,6 +46,7 @@ template class RSA_Decryptor<RSA_BlockType2>;
template
class
RSA_Encryptor
<
RSA_BlockType1
>;
template
class
RSA_Encryptor
<
RSA_BlockType1
>;
template
class
RSA_Encryptor
<
RSA_BlockType2
>;
template
class
RSA_Encryptor
<
RSA_BlockType2
>;
template
void
tcDelete
<
HASH
>(
HASH
*
);
template
void
tcDelete
<
HASH
>(
HASH
*
);
template
void
tcDelete
<
Integer
>(
Integer
*
);
template
void
tcArrayDelete
<
byte
>(
byte
*
);
template
void
tcArrayDelete
<
byte
>(
byte
*
);
template
AllocatorWithCleanup
<
byte
>
::
pointer
StdReallocate
<
byte
,
AllocatorWithCleanup
<
byte
>
>
(
AllocatorWithCleanup
<
byte
>&
,
byte
*
,
AllocatorWithCleanup
<
byte
>::
size_type
,
AllocatorWithCleanup
<
byte
>::
size_type
,
bool
);
template
AllocatorWithCleanup
<
byte
>
::
pointer
StdReallocate
<
byte
,
AllocatorWithCleanup
<
byte
>
>
(
AllocatorWithCleanup
<
byte
>&
,
byte
*
,
AllocatorWithCleanup
<
byte
>::
size_type
,
AllocatorWithCleanup
<
byte
>::
size_type
,
bool
);
template
void
tcArrayDelete
<
word
>(
word
*
);
template
void
tcArrayDelete
<
word
>(
word
*
);
...
...
extra/yassl/taocrypt/test/test.cpp
View file @
a965875a
...
@@ -71,6 +71,7 @@ using TaoCrypt::DH;
...
@@ -71,6 +71,7 @@ using TaoCrypt::DH;
using
TaoCrypt
::
EncodeDSA_Signature
;
using
TaoCrypt
::
EncodeDSA_Signature
;
using
TaoCrypt
::
DecodeDSA_Signature
;
using
TaoCrypt
::
DecodeDSA_Signature
;
using
TaoCrypt
::
PBKDF2_HMAC
;
using
TaoCrypt
::
PBKDF2_HMAC
;
using
TaoCrypt
::
tcArrayDelete
;
...
@@ -117,10 +118,36 @@ struct func_args {
...
@@ -117,10 +118,36 @@ struct func_args {
};
};
/*
DES, AES, Blowfish, and Twofish need aligned (4 byte) input/output for
processing, can turn this off by setting gpBlock(assumeAligned = false)
but would hurt performance. yaSSL always uses dynamic memory so we have
at least 8 byte alignment. This test tried to force alignment for stack
variables (for convenience) but some compiler versions and optimizations
seemed to be off. So we have msgTmp variable which we copy into dynamic
memory at runtime to ensure proper alignment, along with plain/cipher.
Whew!
*/
const
byte
msgTmp
[]
=
{
// "now is the time for all " w/o trailing 0
0x6e
,
0x6f
,
0x77
,
0x20
,
0x69
,
0x73
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x74
,
0x69
,
0x6d
,
0x65
,
0x20
,
0x66
,
0x6f
,
0x72
,
0x20
,
0x61
,
0x6c
,
0x6c
,
0x20
};
byte
*
msg
=
0
;
// for block cipher input
byte
*
plain
=
0
;
// for cipher decrypt comparison
byte
*
cipher
=
0
;
// block output
void
taocrypt_test
(
void
*
args
)
void
taocrypt_test
(
void
*
args
)
{
{
((
func_args
*
)
args
)
->
return_code
=
-
1
;
// error state
((
func_args
*
)
args
)
->
return_code
=
-
1
;
// error state
msg
=
NEW_TC
byte
[
24
];
plain
=
NEW_TC
byte
[
24
];
cipher
=
NEW_TC
byte
[
24
];
memcpy
(
msg
,
msgTmp
,
24
);
int
ret
=
0
;
int
ret
=
0
;
if
(
(
ret
=
sha_test
())
)
if
(
(
ret
=
sha_test
())
)
...
@@ -193,6 +220,9 @@ void taocrypt_test(void* args)
...
@@ -193,6 +220,9 @@ void taocrypt_test(void* args)
else
else
printf
(
"PBKDF2 test passed!
\n
"
);
printf
(
"PBKDF2 test passed!
\n
"
);
tcArrayDelete
(
cipher
);
tcArrayDelete
(
plain
);
tcArrayDelete
(
msg
);
((
func_args
*
)
args
)
->
return_code
=
ret
;
((
func_args
*
)
args
)
->
return_code
=
ret
;
}
}
...
@@ -507,35 +537,26 @@ int des_test()
...
@@ -507,35 +537,26 @@ int des_test()
DES_ECB_Encryption
enc
;
DES_ECB_Encryption
enc
;
DES_ECB_Decryption
dec
;
DES_ECB_Decryption
dec
;
const
int
sz
=
TaoCrypt
::
DES_BLOCK_SIZE
*
3
;
const
byte
key
[]
=
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xab
,
0xcd
,
0xef
};
const
byte
key
[]
=
{
0x01
,
0x23
,
0x45
,
0x67
,
0x89
,
0xab
,
0xcd
,
0xef
};
const
byte
iv
[]
=
{
0x12
,
0x34
,
0x56
,
0x78
,
0x90
,
0xab
,
0xcd
,
0xef
};
const
byte
iv
[]
=
{
0x12
,
0x34
,
0x56
,
0x78
,
0x90
,
0xab
,
0xcd
,
0xef
};
const
byte
vector
[]
=
{
// "Now is the time for all " w/o trailing 0
0x4e
,
0x6f
,
0x77
,
0x20
,
0x69
,
0x73
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x74
,
0x69
,
0x6d
,
0x65
,
0x20
,
0x66
,
0x6f
,
0x72
,
0x20
,
0x61
,
0x6c
,
0x6c
,
0x20
};
byte
plain
[
24
];
byte
cipher
[
24
];
enc
.
SetKey
(
key
,
sizeof
(
key
));
enc
.
SetKey
(
key
,
sizeof
(
key
));
enc
.
Process
(
cipher
,
vector
,
sizeof
(
vector
)
);
enc
.
Process
(
cipher
,
msg
,
sz
);
dec
.
SetKey
(
key
,
sizeof
(
key
));
dec
.
SetKey
(
key
,
sizeof
(
key
));
dec
.
Process
(
plain
,
cipher
,
s
izeof
(
cipher
)
);
dec
.
Process
(
plain
,
cipher
,
s
z
);
if
(
memcmp
(
plain
,
vector
,
sizeof
(
plain
)
))
if
(
memcmp
(
plain
,
msg
,
sz
))
return
-
50
;
return
-
50
;
const
byte
verify1
[]
=
const
byte
verify1
[]
=
{
{
0x
3f
,
0xa4
,
0x0e
,
0x8a
,
0x98
,
0x4d
,
0x48
,
0x15
,
0x
f9
,
0x99
,
0xb8
,
0x8e
,
0xaf
,
0xea
,
0x71
,
0x53
,
0x6a
,
0x27
,
0x17
,
0x87
,
0xab
,
0x88
,
0x83
,
0xf9
,
0x6a
,
0x27
,
0x17
,
0x87
,
0xab
,
0x88
,
0x83
,
0xf9
,
0x89
,
0x3d
,
0x51
,
0xec
,
0x4b
,
0x56
,
0x3b
,
0x53
0x89
,
0x3d
,
0x51
,
0xec
,
0x4b
,
0x56
,
0x3b
,
0x53
};
};
if
(
memcmp
(
cipher
,
verify1
,
s
izeof
(
cipher
)
))
if
(
memcmp
(
cipher
,
verify1
,
s
z
))
return
-
51
;
return
-
51
;
// CBC mode
// CBC mode
...
@@ -543,21 +564,21 @@ int des_test()
...
@@ -543,21 +564,21 @@ int des_test()
DES_CBC_Decryption
dec2
;
DES_CBC_Decryption
dec2
;
enc2
.
SetKey
(
key
,
sizeof
(
key
),
iv
);
enc2
.
SetKey
(
key
,
sizeof
(
key
),
iv
);
enc2
.
Process
(
cipher
,
vector
,
sizeof
(
vector
)
);
enc2
.
Process
(
cipher
,
msg
,
sz
);
dec2
.
SetKey
(
key
,
sizeof
(
key
),
iv
);
dec2
.
SetKey
(
key
,
sizeof
(
key
),
iv
);
dec2
.
Process
(
plain
,
cipher
,
s
izeof
(
cipher
)
);
dec2
.
Process
(
plain
,
cipher
,
s
z
);
if
(
memcmp
(
plain
,
vector
,
sizeof
(
plain
)
))
if
(
memcmp
(
plain
,
msg
,
sz
))
return
-
52
;
return
-
52
;
const
byte
verify2
[]
=
const
byte
verify2
[]
=
{
{
0x
e5
,
0xc7
,
0xcd
,
0xde
,
0x87
,
0x2b
,
0xf2
,
0x7c
,
0x
8b
,
0x7c
,
0x52
,
0xb0
,
0x01
,
0x2b
,
0x6c
,
0xb8
,
0x4
3
,
0xe9
,
0x34
,
0x00
,
0x8c
,
0x38
,
0x9c
,
0x0f
,
0x4
f
,
0x0f
,
0xeb
,
0xf3
,
0xfb
,
0x5f
,
0x86
,
0x73
,
0x
68
,
0x37
,
0x88
,
0x49
,
0x9a
,
0x7c
,
0x05
,
0xf6
0x
15
,
0x85
,
0xb3
,
0x22
,
0x4b
,
0x86
,
0x2b
,
0x4b
};
};
if
(
memcmp
(
cipher
,
verify2
,
s
izeof
(
cipher
)
))
if
(
memcmp
(
cipher
,
verify2
,
s
z
))
return
-
53
;
return
-
53
;
// EDE3 CBC mode
// EDE3 CBC mode
...
@@ -579,21 +600,21 @@ int des_test()
...
@@ -579,21 +600,21 @@ int des_test()
};
};
enc3
.
SetKey
(
key3
,
sizeof
(
key3
),
iv3
);
enc3
.
SetKey
(
key3
,
sizeof
(
key3
),
iv3
);
enc3
.
Process
(
cipher
,
vector
,
sizeof
(
vector
)
);
enc3
.
Process
(
cipher
,
msg
,
sz
);
dec3
.
SetKey
(
key3
,
sizeof
(
key3
),
iv3
);
dec3
.
SetKey
(
key3
,
sizeof
(
key3
),
iv3
);
dec3
.
Process
(
plain
,
cipher
,
s
izeof
(
cipher
)
);
dec3
.
Process
(
plain
,
cipher
,
s
z
);
if
(
memcmp
(
plain
,
vector
,
sizeof
(
plain
)
))
if
(
memcmp
(
plain
,
msg
,
sz
))
return
-
54
;
return
-
54
;
const
byte
verify3
[]
=
const
byte
verify3
[]
=
{
{
0x
43
,
0xa0
,
0x29
,
0x7e
,
0xd1
,
0x84
,
0xf8
,
0x0e
,
0x
08
,
0x8a
,
0xae
,
0xe6
,
0x9a
,
0xa9
,
0xc1
,
0x13
,
0x
89
,
0x64
,
0x84
,
0x32
,
0x12
,
0xd5
,
0x08
,
0x98
,
0x
93
,
0x7d
,
0xf7
,
0x3a
,
0x11
,
0x56
,
0x66
,
0xb3
,
0x18
,
0x
94
,
0x15
,
0x74
,
0x87
,
0x12
,
0x7d
,
0xb0
0x18
,
0x
bc
,
0xbb
,
0x6d
,
0xd2
,
0xb1
,
0x16
,
0xda
};
};
if
(
memcmp
(
cipher
,
verify3
,
s
izeof
(
cipher
)
))
if
(
memcmp
(
cipher
,
verify3
,
s
z
))
return
-
55
;
return
-
55
;
return
0
;
return
0
;
...
@@ -606,18 +627,9 @@ int aes_test()
...
@@ -606,18 +627,9 @@ int aes_test()
AES_CBC_Decryption
dec
;
AES_CBC_Decryption
dec
;
const
int
bs
(
TaoCrypt
::
AES
::
BLOCK_SIZE
);
const
int
bs
(
TaoCrypt
::
AES
::
BLOCK_SIZE
);
const
byte
msg
[]
=
{
// "Now is the time for all " w/o trailing 0
0x6e
,
0x6f
,
0x77
,
0x20
,
0x69
,
0x73
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x74
,
0x69
,
0x6d
,
0x65
,
0x20
,
0x66
,
0x6f
,
0x72
,
0x20
,
0x61
,
0x6c
,
0x6c
,
0x20
};
byte
key
[]
=
"0123456789abcdef "
;
// align
byte
key
[]
=
"0123456789abcdef "
;
// align
byte
iv
[]
=
"1234567890abcdef "
;
// align
byte
iv
[]
=
"1234567890abcdef "
;
// align
byte
cipher
[
bs
];
byte
plain
[
bs
];
enc
.
SetKey
(
key
,
bs
,
iv
);
enc
.
SetKey
(
key
,
bs
,
iv
);
dec
.
SetKey
(
key
,
bs
,
iv
);
dec
.
SetKey
(
key
,
bs
,
iv
);
...
@@ -667,18 +679,9 @@ int twofish_test()
...
@@ -667,18 +679,9 @@ int twofish_test()
Twofish_CBC_Decryption
dec
;
Twofish_CBC_Decryption
dec
;
const
int
bs
(
TaoCrypt
::
Twofish
::
BLOCK_SIZE
);
const
int
bs
(
TaoCrypt
::
Twofish
::
BLOCK_SIZE
);
const
byte
msg
[]
=
{
// "Now is the time for all " w/o trailing 0
0x6e
,
0x6f
,
0x77
,
0x20
,
0x69
,
0x73
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x74
,
0x69
,
0x6d
,
0x65
,
0x20
,
0x66
,
0x6f
,
0x72
,
0x20
,
0x61
,
0x6c
,
0x6c
,
0x20
};
byte
key
[]
=
"0123456789abcdef "
;
// align
byte
key
[]
=
"0123456789abcdef "
;
// align
byte
iv
[]
=
"1234567890abcdef "
;
// align
byte
iv
[]
=
"1234567890abcdef "
;
// align
byte
cipher
[
bs
];
byte
plain
[
bs
];
enc
.
SetKey
(
key
,
bs
,
iv
);
enc
.
SetKey
(
key
,
bs
,
iv
);
dec
.
SetKey
(
key
,
bs
,
iv
);
dec
.
SetKey
(
key
,
bs
,
iv
);
...
@@ -728,18 +731,9 @@ int blowfish_test()
...
@@ -728,18 +731,9 @@ int blowfish_test()
Blowfish_CBC_Decryption
dec
;
Blowfish_CBC_Decryption
dec
;
const
int
bs
(
TaoCrypt
::
Blowfish
::
BLOCK_SIZE
);
const
int
bs
(
TaoCrypt
::
Blowfish
::
BLOCK_SIZE
);
const
byte
msg
[]
=
{
// "Now is the time for all " w/o trailing 0
0x6e
,
0x6f
,
0x77
,
0x20
,
0x69
,
0x73
,
0x20
,
0x74
,
0x68
,
0x65
,
0x20
,
0x74
,
0x69
,
0x6d
,
0x65
,
0x20
,
0x66
,
0x6f
,
0x72
,
0x20
,
0x61
,
0x6c
,
0x6c
,
0x20
};
byte
key
[]
=
"0123456789abcdef "
;
// align
byte
key
[]
=
"0123456789abcdef "
;
// align
byte
iv
[]
=
"1234567890abcdef "
;
// align
byte
iv
[]
=
"1234567890abcdef "
;
// align
byte
cipher
[
bs
*
2
];
byte
plain
[
bs
*
2
];
enc
.
SetKey
(
key
,
16
,
iv
);
enc
.
SetKey
(
key
,
16
,
iv
);
dec
.
SetKey
(
key
,
16
,
iv
);
dec
.
SetKey
(
key
,
16
,
iv
);
...
@@ -805,7 +799,7 @@ int rsa_test()
...
@@ -805,7 +799,7 @@ int rsa_test()
RSAES_Decryptor
dec
(
priv
);
RSAES_Decryptor
dec
(
priv
);
byte
plain
[
64
];
byte
plain
[
64
];
dec
.
Decrypt
(
cipher
,
sizeof
(
cipher
),
plain
,
rng
);
dec
.
Decrypt
(
cipher
,
sizeof
(
plain
),
plain
,
rng
);
if
(
memcmp
(
plain
,
message
,
len
))
if
(
memcmp
(
plain
,
message
,
len
))
return
-
70
;
return
-
70
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment