Skip to content

Commit 2026e28

Browse files
committed
Fix demos/pem-info.c to properly display different CFB modes
Also, make CMake build it.
1 parent dd3b9e5 commit 2026e28

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

demos/CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Options
33
#-----------------------------------------------------------------------------
44
option(BUILD_USEFUL_DEMOS "Build useful demos (hashsum)" FALSE)
5-
option(BUILD_USABLE_DEMOS "Build usable demos (ltcrypt sizes constants)" FALSE)
5+
option(BUILD_USABLE_DEMOS "Build usable demos (ltcrypt sizes constants pem-info)" FALSE)
66

77
#-----------------------------------------------------------------------------
88
# Useful demos
@@ -38,7 +38,7 @@ endif()
3838

3939
if(BUILD_USABLE_DEMOS)
4040

41-
list(APPEND ALL_DEMOS_TARGETS ltcrypt sizes constants)
41+
list(APPEND ALL_DEMOS_TARGETS ltcrypt sizes constants pem-info)
4242

4343
# ltcrypt
4444
add_executable(ltcrypt
@@ -67,6 +67,15 @@ if(BUILD_USABLE_DEMOS)
6767
${PROJECT_NAME}
6868
)
6969

70+
# pem-info
71+
add_executable(pem-info
72+
${CMAKE_CURRENT_SOURCE_DIR}/pem-info.c
73+
)
74+
75+
target_link_libraries(pem-info PRIVATE
76+
${PROJECT_NAME}
77+
)
78+
7079
endif()
7180

7281
#-----------------------------------------------------------------------------

demos/pem-info.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ static const struct {
4949
{ cm_none, "none", },
5050
{ cm_cbc, "CBC", },
5151
{ cm_cfb, "CFB", },
52+
{ cm_cfb1, "CFB1", },
53+
{ cm_cfb8, "CFB8", },
5254
{ cm_ctr, "CTR", },
5355
{ cm_ofb, "OFB", },
5456
{ cm_stream, "STREAM", },
@@ -58,7 +60,7 @@ static const struct {
5860
static const char *s_map_mode(enum cipher_mode mode)
5961
{
6062
size_t n;
61-
mode &= cm_modes;
63+
mode &= cm_modes | cm_1bit | cm_8bit;
6264
for (n = 0; n < sizeof(cipher_mode_map)/sizeof(cipher_mode_map[0]); ++n) {
6365
if (cipher_mode_map[n].mode == mode)
6466
return cipher_mode_map[n].name;

0 commit comments

Comments
 (0)