Move SHA256 class to libroot instead of linking libshared into libroot.

Discussed with PulkoMandy and on the haiku-commits mailing list.

Thanks to @jessicah for compile-testing and fixing 2 small issues I missed.
This commit is contained in:
Augustin Cavalier 2017-10-02 12:35:57 -04:00
parent c1e80b79c1
commit 6aff37d1c7
17 changed files with 38 additions and 23 deletions

View File

@ -0,0 +1 @@
#include "../../../private/libroot/SHA256.h"

View File

@ -1 +0,0 @@
#include <../private/shared/SHA256.h>

View File

@ -2,8 +2,8 @@
* Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#ifndef SHA_256_H
#define SHA_256_H
#ifndef _SHA_256_H
#define _SHA_256_H
#include <SupportDefs.h>
@ -11,6 +11,8 @@
#define SHA_DIGEST_LENGTH 32
namespace BPrivate {
class SHA256 {
public:
@ -36,4 +38,9 @@ private:
};
#endif // SHA_256_H
} // namespace BPrivate
using BPrivate::SHA256;
#endif // _SHA_256_H

View File

@ -1,6 +1,6 @@
SubDir HAIKU_TOP src bin package ;
UsePrivateHeaders kernel shared storage support ;
UsePrivateHeaders kernel libroot shared storage support ;
BinCommand package :
command_add.cpp

View File

@ -1,6 +1,6 @@
SubDir HAIKU_TOP src build libpackage ;
UsePrivateBuildHeaders kernel package shared storage support ;
UsePrivateBuildHeaders kernel package shared libroot storage support ;
UseHeaders [ FDirName $(HAIKU_TOP) headers os net ] : true ;

View File

@ -9,7 +9,7 @@ UseHeaders [ FDirName $(HAIKU_TOP) headers build os interface ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) headers build os storage ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) headers build os support ] : true ;
UsePrivateBuildHeaders kernel system ;
UsePrivateBuildHeaders kernel libroot system ;
{
local defines = [ FDefines
@ -29,7 +29,6 @@ UsePrivateBuildHeaders kernel system ;
defines = [ FDefines KMESSAGE_CONTAINER_ONLY=1 ] ;
ObjectC++Flags KMessage.cpp : $(defines) ;
}
# locate the library
@ -65,6 +64,7 @@ local librootSources =
misc.cpp
sem.cpp
thread.cpp
SHA256.cpp
$(hostPlatformSources)
@ -100,5 +100,7 @@ SEARCH on [ FGristFiles driver_settings.cpp ]
= [ FDirName $(HAIKU_TOP) src system libroot os ] ;
SEARCH on [ FGristFiles $(strlSources) strnlen.cpp ]
= [ FDirName $(HAIKU_TOP) src system libroot posix string ] ;
SEARCH on [ FGristFiles SHA256.cpp ]
= [ FDirName $(HAIKU_TOP) src system libroot posix crypt ] ;
SEARCH on [ FGristFiles KMessage.cpp ]
= [ FDirName $(HAIKU_TOP) src system kernel messaging ] ;

View File

@ -11,10 +11,9 @@ SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src kits shared ] ;
BuildPlatformStaticLibraryPIC libshared_build.a :
Keymap.cpp
NaturalCompare.cpp
SHA256.cpp
RegExp.cpp
:
# no shared libs, but will require 'libgnuregex' dynamic library on Darwin
;

View File

@ -4,6 +4,7 @@ UsePrivateHeaders
app
kernel
shared
libroot
storage
support
;

View File

@ -54,7 +54,6 @@ for architectureObject in [ MultiArchSubDirSetup ] {
RegExp.cpp
RWLocker.cpp
RWLockManager.cpp
SHA256.cpp
ShakeTrackingFilter.cpp
StringForRate.cpp
StringForSize.cpp

View File

@ -85,7 +85,6 @@ for architectureObject in [ MultiArchSubDirSetup ] {
$(librootNoDebugObjects)
[ TargetStaticLibsupc++ ]
[ TargetLibgcc ]
shared
;
# Use the standard libroot.so soname, so when the debug version is
@ -100,9 +99,8 @@ for architectureObject in [ MultiArchSubDirSetup ] {
$(librootDebugObjects)
[ TargetStaticLibsupc++ ]
[ TargetLibgcc ]
shared
;
StaticLibrary [ MultiArchDefaultGristFiles libm.a ] : empty.c ;
StaticLibrary [ MultiArchDefaultGristFiles libpthread.a ] : empty.c ;

View File

@ -1,6 +1,6 @@
SubDir HAIKU_TOP src system libroot posix crypt ;
UsePrivateHeaders shared ;
UsePrivateHeaders libroot ;
UsePrivateSystemHeaders ;
local architectureObject ;
@ -20,6 +20,7 @@ for architectureObject in [ MultiArchSubDirSetup ] {
crypto_scrypt.cpp
crypt.cpp
pbkdf2.cpp
SHA256.cpp
;
}
}

View File

@ -12,6 +12,9 @@
#include <ByteOrder.h>
namespace BPrivate {
static const uint32 kChunkSize = 64; // 64 bytes == 512 bits
static const uint32 kRounds[64] = {
@ -188,3 +191,6 @@ SHA256::_ProcessChunk()
fHash[6] += g;
fHash[7] += h;
}
} // namespace BPrivate

View File

@ -29,6 +29,7 @@
#include <stdint.h>
#include <string.h>
#include <ByteOrder.h>
#include "pbkdf2.h"
/* Function which does the zeroing. */

View File

@ -3,6 +3,7 @@ SubDir HAIKU_TOP src tests system kernel file_corruption driver ;
SubDirHdrs $(HAIKU_TOP) src system kernel device_manager ;
UsePrivateKernelHeaders ;
UsePrivateHeaders libroot ;
UseHeaders [ FDirName $(SUBDIR) $(DOTDOT) ] ;
@ -19,4 +20,4 @@ KernelAddon checksum_device :
SEARCH on [ FGristFiles SHA256.cpp ]
= [ FDirName $(HAIKU_TOP) src kits shared ] ;
= [ FDirName $(HAIKU_TOP) src system libroot posix crypt ] ;

View File

@ -2,7 +2,7 @@ SubDir HAIKU_TOP src tests system kernel file_corruption fs ;
UsePrivateKernelHeaders ;
UsePrivateHeaders shared ;
UsePrivateHeaders libroot ;
UseHeaders [ FDirName $(SUBDIR) $(DOTDOT) ] ;
@ -36,7 +36,7 @@ KernelAddon checksumfs :
# from packagefs
DebugSupport.cpp
# from src/kits/shared
# from src/system/libroot/posix/crypt
SHA256.cpp
;
@ -44,6 +44,6 @@ KernelAddon checksumfs :
SEARCH on [ FGristFiles DebugSupport.cpp ]
= [ FDirName $(HAIKU_TOP) src add-ons kernel file_systems packagefs ] ;
SEARCH on [ FGristFiles SHA256.cpp ]
= [ FDirName $(HAIKU_TOP) src kits shared ] ;
= [ FDirName $(HAIKU_TOP) src system libroot posix crypt ] ;
HaikuSubInclude userland ;

View File

@ -2,7 +2,7 @@ SubDir HAIKU_TOP src tests system kernel file_corruption fs userland ;
UsePrivateKernelHeaders ;
UsePrivateHeaders shared ;
UsePrivateHeaders libroot ;
UseHeaders [ FDirName $(SUBDIR) $(DOTDOT) $(DOTDOT) ] ;
@ -36,4 +36,4 @@ Addon <userland>checksumfs :
SEARCH on [ FGristFiles DebugSupport.cpp ]
= [ FDirName $(HAIKU_TOP) src add-ons kernel file_systems packagefs ] ;
SEARCH on [ FGristFiles SHA256.cpp ]
= [ FDirName $(HAIKU_TOP) src kits shared ] ;
= [ FDirName $(HAIKU_TOP) src system libroot posix crypt ] ;

View File

@ -1,6 +1,6 @@
SubDir HAIKU_TOP src tools package ;
UsePrivateBuildHeaders shared kernel storage support ;
UsePrivateBuildHeaders libroot shared kernel storage support ;
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src bin package ] ;