Git Product home page Git Product logo

Comments (8)

RazviOverflow avatar RazviOverflow commented on June 29, 2024

I managed to "solve" the errors by removing the std part of every std::toupper() or std::isspace() call. That is, the calls are now ::toupper() and ::isspace().

However, now I am getting the following warnings (they are warnings, nevertheless):

1>c:\users\user\desktop\cryptopp-master\cryptopp-master\pem_read.cpp(1168): warning C4100: 'cert': unreferenced formal parameter
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\algorithm(1443): warning C4242: '=': conversion from 'int' to 'char', possible loss of data
1>c:\users\user\desktop\cryptopp-master\cryptopp-master\pem_read.cpp(319): note: see reference to function template instantiation '_OutIt std::transform<std::_String_iterator<std::_String_val<std::_Simple_types<_Ty>>>,std::_String_iterator<std::_String_val<std::_Simple_types<_Ty>>>,int(__cdecl *)(int)>(const _InIt,const _InIt,_OutIt,_Fn)' being compiled
1>        with
1>        [
1>            _OutIt=std::_String_iterator<std::_String_val<std::_Simple_types<char>>>,
1>            _Ty=char,
1>            _InIt=std::_String_iterator<std::_String_val<std::_Simple_types<char>>>,
1>            _Fn=int (__cdecl *)(int)
1>        ]
1>pem_write.cpp
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\algorithm(1443): warning C4242: '=': conversion from 'int' to 'char', possible loss of data
1>c:\users\user\desktop\cryptopp-master\cryptopp-master\pem_write.cpp(321): note: see reference to function template instantiation '_OutIt std::transform<std::_String_iterator<std::_String_val<std::_Simple_types<_Ty>>>,std::_String_iterator<std::_String_val<std::_Simple_types<_Ty>>>,int(__cdecl *)(int)>(const _InIt,const _InIt,_OutIt,_Fn)' being compiled
1>        with
1>        [
1>            _OutIt=std::_String_iterator<std::_String_val<std::_Simple_types<char>>>,
1>            _Ty=char,
1>            _InIt=std::_String_iterator<std::_String_val<std::_Simple_types<char>>>,
1>            _Fn=int (__cdecl *)(int)
1>        ]

It might be working but this is just a patch in my local version of Cryptopp-PEM. A fix must be addressed.

from cryptopp-pem.

noloader avatar noloader commented on June 29, 2024

Thanks @RazviOverflow.

Sorry about the troubles. I don't think I have ever compiled this on Visual Studio. Let me give it a whirl.

I'd like to try to keep std::toupper and std::isspace. I suspect the problem has to do with C++ and overloads of std::toupper and std::isspace.

The problem with gf2n.h is kind of interesting. That header is Crypto++ proper. That should be well tested and should not have a problem.

from cryptopp-pem.

noloader avatar noloader commented on June 29, 2024

Thanks again @RazviOverflow.

Give Commit ac4c98d779bfa8e4 a try. It compiles cleanly under Visual Studio using /W4.

We needed to avoid std::stransform and add ToLower(secure_string) and ToUpper(secure_string). We needed the new functions so we could make a cast to quiet the warnings caused by tolower and toupper using an int rather than a char.

from cryptopp-pem.

RazviOverflow avatar RazviOverflow commented on June 29, 2024

Hello again @noloader, you are most welcome! Glad to help.

I manually changed everything in order to make it compile. Tomorrow I will try your ac4c98d779bfa8e4 and afterwards post here my feedback.

Until then, could you tell me how did you import/compile it in MVS? Did you import latest Crypto++ version and add headers and sources into their respective folders or there is something else to it?

from cryptopp-pem.

noloader avatar noloader commented on June 29, 2024

@RazviOverflow,

could you tell me how did you import/compile it in MVS?

I test the source files from the command line using cryptest.nmake:

> cd cryptopp
> copy ..\crpytopp-pem\*.h .
> copy ..\crpytopp-pem\*.cpp .
> git diff
diff --git a/cryptest.nmake b/cryptest.nmake
index b4b47973..2b42b936 100644
--- a/cryptest.nmake
+++ b/cryptest.nmake
@@ -84,7 +84,8 @@ LIB_SRCS = \
     sse_simd.cpp strciphr.cpp tea.cpp tftables.cpp threefish.cpp tiger.cpp \
     tigertab.cpp ttmac.cpp tweetnacl.cpp twofish.cpp vmac.cpp wake.cpp \
     whrlpool.cpp xed25519.cpp xtr.cpp xtrcrypt.cpp xts.cpp zdeflate.cpp \
-    zinflate.cpp zlib.cpp
+    zinflate.cpp zlib.cpp \
+    pem_common.cpp pem_read.cpp pem_write.cpp

 LIB_OBJS = \
     cryptlib.obj cpu.obj integer.obj 3way.obj adler32.obj algebra.obj \
@@ -115,7 +116,8 @@ LIB_OBJS = \
     sse_simd.obj strciphr.obj tea.obj tftables.obj threefish.obj tiger.obj \
     tigertab.obj ttmac.obj tweetnacl.obj twofish.obj vmac.obj wake.obj \
     whrlpool.obj xed25519.obj xtr.obj xtrcrypt.obj xts.obj zdeflate.obj \
-    zinflate.obj zlib.obj
+    zinflate.obj zlib.obj \
+    pem_common.obj pem_read.obj pem_write.obj

 ASM_OBJS = \
     rdrand-x86.obj rdrand-x64.obj rdseed-x86.obj rdseed-x64.obj x64masm.obj x64dll.obj

Once cryptest.nmake completes, you have the cryptlib.lib and cryptest.exe in the root of cryptopp folder. It is easier than messing around with the the Visual Studio solution and project files.

from cryptopp-pem.

noloader avatar noloader commented on June 29, 2024

@RazviOverflow,

You will also need Commit 3833d017c6fb. I missed the compile error last time around. I think Nmake failed to build a file that was updated. Or I forgot to copy the updated file into the cryptopp directory.

from cryptopp-pem.

RazviOverflow avatar RazviOverflow commented on June 29, 2024

I explicitly need to use MVS for this project. I will describe step-by-step how I managed to get it working, just for the record @noloader.

  1. Download Crypto++ version 8.5.0 https://github.com/weidai11/cryptopp/releases/tag/CRYPTOPP_8_5_0 and unzip the contents.
  2. Download the latest version 3833d01 and paste the files straight into Crypto++'s folder (where all the .cpp and .h files are).
  3. Open cryptlib.vcxproj in MVS (2017 in my case). You should see 4 projects: cryptdll, cryptest, cryptlib and dlltest.
  4. Open the cryptlib's dropdown menu.
  5. Right click Header Files -> Add -> Existing Item and select pem.h and pem_common.h.
  6. Right click Source Files -> Add -> Existing Item and select pem_common.cpp, pem_read.cpp and .pem_write.cpp
  7. Right click cryptlib and click Build (after selecting the configuration you want Debug/Release and x86/x64).
    Compilation was unsuccessful, reporting the following errors:
1>pem_common.cpp
1>c:\users\user\desktop\cryptopp-master\cryptopp-master\pem_common.cpp(269): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "pch.h"' to your source?
1>pem_read.cpp
1>c:\users\user\desktop\cryptopp-master\cryptopp-master\pem_read.cpp(1259): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "pch.h"' to your source?
1>pem_write.cpp
1>c:\users\user\desktop\cryptopp-master\cryptopp-master\pem_write.cpp(634): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "pch.h"' to your source?
  1. In order to solve it, I manually added #include "pch.h" at the beginning of pem_commong.cpp, pem_read.cpp and pem.write.cpp.

Then I built the project again and it finished with no errors and just 3 LNK4221 warnings that I guess are related to MVS and not the library itself.

1>Generating Code...
1>simple.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
1>polynomi.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
1>algebra.obj : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
1>cryptlib.vcxproj -> C:\Users\User\Desktop\cryptopp-master\cryptopp-master\x64\Output\Release\cryptlib.lib
1>Done building project "cryptlib.vcxproj".
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

Hope it helps.
Thank you once again @noloader

from cryptopp-pem.

noloader avatar noloader commented on June 29, 2024

@RazviOverflow,

I added the precompiled header include at Commit 2b20f9292e3c. That probably should have been there a long time ago.

The linker warnings are par for the course. We have not been able to squash them. They are present because the *.cpp file is included in the *.h file in certain configurations.

There's also a x509cert.cpp you can include if you want to parse certificates. Also see https://cryptopp.com/wiki/X509Certificate on the wiki.

from cryptopp-pem.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.