[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,6 +2,6 @@
<service name="tar_git">
<param name="url">https://github.com/monich/harbour-foilnotes.git</param>
<param name="branch">master</param>
- <param name="revision">629469a</param>
+ <param name="revision">58cf946</param>
</service>
</services>
\ No newline at end of file
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/app.pro
^
|
@@ -12,16 +12,18 @@
PKGCONFIG += sailfishapp mlite5 glib-2.0 gobject-2.0
QT += qml quick sql
-openssl_static {
- LIBS += $$[QT_INSTALL_LIBS]/libcrypto.a $$[QT_INSTALL_LIBS]/libssl.a
- PKGCONFIG += zlib
+QMAKE_CXXFLAGS += -Wno-unused-parameter
+QMAKE_CFLAGS += -Wno-unused-parameter
+
+system("pkg-config openssl --atleast-version=1.1") {
+ message("Linking OpenSSL dynamically")
+ PKGCONFIG += libcrypto
} else {
- PKGCONFIG += libcrypto
+ message("Linking OpenSSL statically")
+ LIBS += $$[QT_INSTALL_LIBS]/libcrypto.a
+ PKGCONFIG += zlib
}
-QMAKE_CXXFLAGS += -Wno-unused-parameter -Wno-psabi
-QMAKE_CFLAGS += -Wno-unused-parameter
-
app_settings {
# This path is hardcoded in jolla-settings
TRANSLATIONS_PATH = /usr/share/translations
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/VERSION
^
|
@@ -1 +1 @@
-1.0.21
+1.0.23
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/debian/changelog
^
|
@@ -1,3 +1,17 @@
+libfoil (1.0.23) unstable; urgency=low
+
+ * Replaced FoilParsePos with GUtilRange
+ * Added foil_asn1_parse_tag()
+ * Allow side-linking with libglibutil
+
+ -- Slava Monich <slava@monich.com> Thu, 21 Oct 2021 04:44:25 +0300
+
+libfoil (1.0.22) unstable; urgency=low
+
+ * Added support for SHA512
+
+ -- Slava Monich <slava@monich.com> Sun, 18 Apr 2021 02:23:14 +0300
+
libfoil (1.0.21) unstable; urgency=low
* Fixed compilation warnings
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/debian/control
^
|
@@ -2,19 +2,19 @@
Section: libs
Priority: optional
Maintainer: Slava Monich <slava@monich.com>
-Build-Depends: debhelper (>= 7), libglibutil-dev (>= 1.0.24), libglib2.0-dev, libpng-dev, libmagic-dev, libssl-dev
+Build-Depends: debhelper (>= 7), libglibutil-dev (>= 1.0.54), libglib2.0-dev, libpng-dev, libmagic-dev, libssl-dev
Standards-Version: 3.8.4
Package: libfoil
Section: libs
Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, libglibutil (>= 1.0.24)
+Depends: ${shlibs:Depends}, ${misc:Depends}, libglibutil (>= 1.0.54)
Description: Library of glib-based cryptography utilities
Package: libfoil-dev
Section: libdevel
Architecture: any
-Depends: libfoil (= ${binary:Version}), ${misc:Depends}, libglibutil-dev (>= 1.0.24)
+Depends: libfoil (= ${binary:Version}), ${misc:Depends}, libglibutil-dev (>= 1.0.54)
Description: Development files for libfoil
Package: foil-tools
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/libfoil/Makefile
^
|
@@ -10,7 +10,31 @@
IMPL = openssl
IMPL_PKG = libcrypto
-PKGS = $(IMPL_PKG) libglibutil glib-2.0 gobject-2.0
+PKGS = $(IMPL_PKG) glib-2.0 gobject-2.0
+
+ifeq ($(LIBGLIBUTIL_PATH),)
+
+# Assume that libglibutil devel package is installed
+PKGS += libglibutil
+
+else
+
+# Side-by-side build
+INCLUDES += -I$(LIBGLIBUTIL_PATH)/include
+DEBUG_LIBS = -L$(LIBGLIBUTIL_PATH)/build/debug -lglibutil
+RELEASE_LIBS = -L$(LIBGLIBUTIL_PATH)/build/release -lglibutil
+DEBUG_DEPS = libglibutil_debug
+RELEASE_DEPS = libglibutil_release
+
+.PHONY: libglibutil_debug libglibutil_release
+
+libglibutil_debug:
+ $(MAKE) -C $(LIBGLIBUTIL_PATH) debug
+
+libglibutil_release:
+ $(MAKE) -C $(LIBGLIBUTIL_PATH) release
+
+endif
#
# Default target
@@ -57,6 +81,7 @@
foil_digest_md5.c \
foil_digest_sha1.c \
foil_digest_sha256.c \
+ foil_digest_sha512.c \
foil_hmac.c \
foil_input.c \
foil_input_base64.c \
@@ -91,6 +116,7 @@
foil_openssl_digest_md5.c \
foil_openssl_digest_sha1.c \
foil_openssl_digest_sha256.c \
+ foil_openssl_digest_sha512.c \
foil_openssl_key_des.c \
foil_openssl_key_rsa_private.c \
foil_openssl_key_rsa_public.c \
@@ -119,7 +145,7 @@
CC ?= $(CROSS_COMPILE)gcc
LD = $(CC)
WARNINGS = -Wall
-INCLUDES = -I$(INCLUDE_DIR) -I$(SRC_DIR)
+INCLUDES += -I$(INCLUDE_DIR) -I$(SRC_DIR)
BASE_FLAGS = -fPIC
FULL_CFLAGS = $(BASE_FLAGS) $(CFLAGS) $(DEFINES) $(WARNINGS) $(INCLUDES) \
-MMD -MP $(shell pkg-config --cflags $(PKGS))
@@ -134,8 +160,8 @@
RELEASE_FLAGS += -g
endif
-DEBUG_LDFLAGS = $(FULL_LDFLAGS) $(DEBUG_FLAGS)
-RELEASE_LDFLAGS = $(FULL_LDFLAGS) $(RELEASE_FLAGS)
+DEBUG_LDFLAGS = $(DEBUG_FLAGS) $(DEBUG_LIBS) $(FULL_LDFLAGS)
+RELEASE_LDFLAGS = $(RELEASE_FLAGS) $(RELEASE_LIBS) $(FULL_LDFLAGS)
DEBUG_CFLAGS = $(FULL_CFLAGS) $(DEBUG_FLAGS) -DDEBUG
RELEASE_CFLAGS = $(FULL_CFLAGS) $(RELEASE_FLAGS) -O2
@@ -157,6 +183,14 @@
RELEASE_OBJS = $(BASE_RELEASE_OBJS) $(IMPL_RELEASE_OBJS)
COVERAGE_OBJS = $(BASE_COVERAGE_OBJS) $(IMPL_COVERAGE_OBJS)
+DEBUG_SO = $(DEBUG_BUILD_DIR)/$(LIB_SO)
+DEBUG_LIB = $(DEBUG_BUILD_DIR)/$(LIB)
+RELEASE_SO = $(RELEASE_BUILD_DIR)/$(LIB_SO)
+RELEASE_LIB = $(RELEASE_BUILD_DIR)/$(LIB)
+COVERAGE_LIB = $(COVERAGE_BUILD_DIR)/$(LIB)
+DEBUG_LINK = $(DEBUG_BUILD_DIR)/$(LIB_SYMLINK1)
+RELEASE_LINK = $(RELEASE_BUILD_DIR)/$(LIB_SYMLINK1)
+
#
# Dependencies
#
@@ -169,6 +203,8 @@
endif
$(PKGCONFIG): | $(BUILD_DIR)
+$(DEBUG_SO): | $(DEBUG_DEPS)
+$(RELEASE_SO): | $(RELEASE_DEPS)
$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
$(COVERAGE_OBJS): | $(COVERAGE_BUILD_DIR)
@@ -180,14 +216,6 @@
# Rules
#
-DEBUG_SO = $(DEBUG_BUILD_DIR)/$(LIB_SO)
-DEBUG_LIB = $(DEBUG_BUILD_DIR)/$(LIB)
-RELEASE_SO = $(RELEASE_BUILD_DIR)/$(LIB_SO)
-RELEASE_LIB = $(RELEASE_BUILD_DIR)/$(LIB)
-COVERAGE_LIB = $(COVERAGE_BUILD_DIR)/$(LIB)
-DEBUG_LINK = $(DEBUG_BUILD_DIR)/$(LIB_SYMLINK1)
-RELEASE_LINK = $(RELEASE_BUILD_DIR)/$(LIB_SYMLINK1)
-
debug: $(DEBUG_LIB) $(DEBUG_SO) $(DEBUG_LINK)
release: $(RELEASE_LIB) $(RELEASE_SO) $(RELEASE_LINK)
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/libfoil/include/foil_asn1.h
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2016-2018 by Slava Monich
+ * Copyright (C) 2016-2021 by Slava Monich <slava@monich.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
- * 1.Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2.Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING
- * IN ANY WAY OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
@@ -40,78 +45,78 @@
gboolean
foil_asn1_is_block_header(
- const FoilParsePos* pos,
+ const GUtilRange* pos,
guint32* total_len);
gboolean
foil_asn1_is_sequence(
- const FoilParsePos* pos);
+ const GUtilRange* pos);
gboolean
foil_asn1_is_integer(
- const FoilParsePos* pos);
+ const GUtilRange* pos);
/* Since 1.0.7 */
gboolean
foil_asn1_is_bit_string(
- const FoilParsePos* pos);
+ const GUtilRange* pos);
gboolean
foil_asn1_is_octet_string(
- const FoilParsePos* pos);
+ const GUtilRange* pos);
gboolean
foil_asn1_is_ia5_string(
- const FoilParsePos* pos);
+ const GUtilRange* pos);
gboolean
foil_asn1_parse_skip_sequence_header(
- FoilParsePos* pos,
+ GUtilRange* pos,
guint32* len);
gboolean
foil_asn1_parse_start_sequence(
- FoilParsePos* pos,
+ GUtilRange* pos,
guint32* len);
/* Since 1.0.7 */
gboolean
foil_asn1_parse_start_bit_string(
- FoilParsePos* pos,
+ GUtilRange* pos,
guint32* num_bytes,
guint8* unused_bits);
gboolean
foil_asn1_parse_integer_bytes(
- FoilParsePos* pos,
+ GUtilRange* pos,
FoilBytes* bytes);
gboolean
foil_asn1_parse_int32(
- FoilParsePos* pos,
+ GUtilRange* pos,
gint32* value);
/* Since 1.0.7 */
gboolean
foil_asn1_parse_bit_string(
- FoilParsePos* pos,
+ GUtilRange* pos,
FoilBytes* bytes,
guint8* unused_bits);
/* Since 1.0.8 */
gboolean
foil_asn1_parse_object_id(
- FoilParsePos* pos,
+ GUtilRange* pos,
FoilBytes* oid_bytes);
gboolean
foil_asn1_parse_octet_string(
- FoilParsePos* pos,
+ GUtilRange* pos,
FoilBytes* bytes);
gboolean
foil_asn1_parse_ia5_string(
- FoilParsePos* pos,
+ GUtilRange* pos,
FoilBytes* bytes);
gsize
@@ -124,7 +129,7 @@
gboolean
foil_asn1_parse_len(
- FoilParsePos* pos,
+ GUtilRange* pos,
guint32* len,
gboolean* def);
@@ -233,6 +238,13 @@
foil_asn1_encode_ia5_string_bytes(
const char* str);
+/* Since 1.0.23 */
+gboolean
+foil_asn1_parse_tag(
+ GUtilRange* pos,
+ guint8* tag_id, /* Full tag or just leading octet for multi-byte tags */
+ guint32* tag_num);
+
G_END_DECLS
#endif /* FOIL_ASN1_H */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/libfoil/include/foil_digest.h
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2018 by Slava Monich
+ * Copyright (C) 2016-2021 by Slava Monich
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -11,6 +11,9 @@
* notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@@ -110,13 +113,16 @@
GType foil_impl_digest_md5_get_type(void);
GType foil_impl_digest_sha1_get_type(void);
GType foil_impl_digest_sha256_get_type(void);
+GType foil_impl_digest_sha512_get_type(void); /* Since 1.0.22 */
#define FOIL_DIGEST_MD5 (foil_impl_digest_md5_get_type())
#define FOIL_DIGEST_SHA1 (foil_impl_digest_sha1_get_type())
#define FOIL_DIGEST_SHA256 (foil_impl_digest_sha256_get_type())
+#define FOIL_DIGEST_SHA512 (foil_impl_digest_sha512_get_type())
#define foil_digest_new_md5() foil_digest_new(FOIL_DIGEST_MD5)
#define foil_digest_new_sha1() foil_digest_new(FOIL_DIGEST_SHA1)
#define foil_digest_new_sha256() foil_digest_new(FOIL_DIGEST_SHA256)
+#define foil_digest_new_sha512() foil_digest_new(FOIL_DIGEST_SHA512)
G_END_DECLS
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/libfoil/include/foil_types.h
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2016-2019 by Slava Monich
+ * Copyright (C) 2016-2021 by Slava Monich <slava@monich.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
- * 1.Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2.Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING
- * IN ANY WAY OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
@@ -49,10 +54,7 @@
gsize len;
} FoilBytes;
-typedef struct foil_parse_pos {
- const guint8* ptr;
- const guint8* end;
-} FoilParsePos;
+#define FoilParsePos GUtilRange
#define FOIL_ERROR (foil_error_quark())
GQuark foil_error_quark(void);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/libfoil/include/foil_util.h
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2016 by Slava Monich
+ * Copyright (C) 2016-2021 by Slava Monich <slava@monich.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
- * 1.Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2.Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING
- * IN ANY WAY OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
@@ -51,16 +56,16 @@
void
foil_parse_skip_spaces(
- FoilParsePos* pos);
+ GUtilRange* pos);
gboolean
foil_parse_skip_bytes(
- FoilParsePos* pos,
+ GUtilRange* pos,
const FoilBytes* bytes);
GBytes*
foil_parse_base64(
- FoilParsePos* pos,
+ GUtilRange* pos,
guint flags);
G_END_DECLS
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/libfoil/libfoil.dsp
^
|
@@ -124,6 +124,10 @@
# End Source File
# Begin Source File
+SOURCE=.\src\foil_digest_sha512.c
+# End Source File
+# Begin Source File
+
SOURCE=.\src\foil_hmac.c
# End Source File
# Begin Source File
@@ -404,6 +408,10 @@
# End Source File
# Begin Source File
+SOURCE=.\src\openssl\foil_openssl_digest_sha512.c
+# End Source File
+# Begin Source File
+
SOURCE=.\src\openssl\foil_openssl_key_des.c
# End Source File
# Begin Source File
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/libfoil/src/foil_asn1.c
^
|
@@ -5,22 +5,27 @@
* modification, are permitted provided that the following conditions
* are met:
*
- * 1.Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2.Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING
- * IN ANY WAY OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
@@ -38,7 +43,7 @@
*/
gboolean
foil_asn1_parse_len(
- FoilParsePos* pos,
+ GUtilRange* pos,
guint32* len,
gboolean* def)
{
@@ -90,7 +95,7 @@
const unsigned int n = x & 0x7f;
ptr = foil_input_peek(in, off+n+1, &available);
if (available >= (off+n+1)) {
- FoilParsePos pos;
+ GUtilRange pos;
pos.ptr = ptr + off;
pos.end = pos.ptr + available - off;
if (foil_asn1_parse_len(&pos, len, def)) {
@@ -129,11 +134,11 @@
*/
gboolean
foil_asn1_is_block_header(
- const FoilParsePos* pos,
+ const GUtilRange* pos,
guint32* total_len)
{
if (pos->ptr < pos->end) {
- FoilParsePos tmp = *pos;
+ GUtilRange tmp = *pos;
guint32 data_len;
gboolean def;
tmp.ptr++;
@@ -151,7 +156,7 @@
gboolean
foil_asn1_is_sequence(
- const FoilParsePos* pos)
+ const GUtilRange* pos)
{
return pos->ptr < pos->end &&
(pos->ptr[0] & (~ASN1_CLASS_MASK)) ==
@@ -160,7 +165,7 @@
gboolean
foil_asn1_is_integer(
- const FoilParsePos* pos)
+ const GUtilRange* pos)
{
return pos->ptr < pos->end &&
(pos->ptr[0] & (~ASN1_CLASS_MASK)) == ASN1_TAG_INTEGER;
@@ -168,7 +173,7 @@
gboolean
foil_asn1_is_bit_string(
- const FoilParsePos* pos)
+ const GUtilRange* pos)
{
return pos->ptr < pos->end &&
(pos->ptr[0] & (~ASN1_CLASS_MASK)) == ASN1_TAG_BIT_STRING;
@@ -176,7 +181,7 @@
gboolean
foil_asn1_is_octet_string(
- const FoilParsePos* pos)
+ const GUtilRange* pos)
{
return pos->ptr < pos->end &&
(pos->ptr[0] & (~ASN1_CLASS_MASK)) == ASN1_TAG_OCTET_STRING;
@@ -184,7 +189,7 @@
gboolean
foil_asn1_is_ia5_string(
- const FoilParsePos* pos)
+ const GUtilRange* pos)
{
return pos->ptr < pos->end &&
(pos->ptr[0] & (~ASN1_CLASS_MASK)) == ASN1_TAG_IA5_STRING;
@@ -193,10 +198,10 @@
static
gboolean
foil_asn1_parse_skip_header(
- FoilParsePos* pos,
+ GUtilRange* pos,
guint32* len)
{
- FoilParsePos tmp = *pos;
+ GUtilRange tmp = *pos;
guint32 seq_len;
gboolean def;
tmp.ptr++;
@@ -210,7 +215,7 @@
gboolean
foil_asn1_parse_skip_sequence_header(
- FoilParsePos* pos,
+ GUtilRange* pos,
guint32* len)
{
return foil_asn1_is_sequence(pos) &&
@@ -219,11 +224,11 @@
gboolean
foil_asn1_parse_start_sequence(
- FoilParsePos* pos,
+ GUtilRange* pos,
guint32* len)
{
guint32 seq_len;
- FoilParsePos tmp = *pos;
+ GUtilRange tmp = *pos;
if (foil_asn1_parse_skip_sequence_header(&tmp, &seq_len) &&
/* Overflow can occur on 32-bit systems */
tmp.ptr + seq_len >= tmp.ptr &&
@@ -237,12 +242,12 @@
gboolean
foil_asn1_parse_start_bit_string(
- FoilParsePos* pos,
+ GUtilRange* pos,
guint32* num_bytes,
guint8* unused_bits)
{
if (foil_asn1_is_bit_string(pos)) {
- FoilParsePos tmp = *pos;
+ GUtilRange tmp = *pos;
guint32 len;
if (foil_asn1_parse_skip_header(&tmp, &len) &&
/* Overflow can occur on 32-bit systems */
@@ -392,11 +397,11 @@
gboolean
foil_asn1_parse_integer_bytes(
- FoilParsePos* pos,
+ GUtilRange* pos,
FoilBytes* bytes)
{
if (foil_asn1_is_integer(pos)) {
- FoilParsePos tmp = *pos;
+ GUtilRange tmp = *pos;
guint32 len;
tmp.ptr++;
/*
@@ -419,11 +424,11 @@
gboolean
foil_asn1_parse_int32(
- FoilParsePos* pos,
+ GUtilRange* pos,
gint32* value)
{
FoilBytes bytes;
- FoilParsePos tmp = *pos;
+ GUtilRange tmp = *pos;
if (foil_asn1_parse_integer_bytes(&tmp, &bytes) && bytes.len <= 4) {
if (value) {
*value = foil_asn1_decode_int32(&bytes);
@@ -437,13 +442,13 @@
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/libfoil/src/foil_asn1_p.h
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2018 by Slava Monich
+ * Copyright (C) 2016-2021 by Slava Monich
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
- * 1.Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2.Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING
- * IN ANY WAY OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
@@ -59,6 +64,7 @@
#define ASN1_TAG_GENERAL_STRING (0x1B)
#define ASN1_TAG_UNIVERSAL_STRING (0x1C)
#define ASN1_TAG_BMP_STRING (0x1E)
+#define ASN1_TAG_NUMBER_MASK (0x1F)
#endif /* FOIL_ASN1_P_H */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/libfoil/src/foil_digest_p.h
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2018 by Slava Monich
+ * Copyright (C) 2016-2021 by Slava Monich
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -11,6 +11,9 @@
* notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@@ -55,20 +58,24 @@
typedef FoilDigest FoilDigestMD5;
typedef FoilDigest FoilDigestSHA1;
typedef FoilDigest FoilDigestSHA256;
+typedef FoilDigest FoilDigestSHA512;
typedef FoilDigestClass FoilDigestMD5Class;
typedef FoilDigestClass FoilDigestSHA1Class;
typedef FoilDigestClass FoilDigestSHA256Class;
+typedef FoilDigestClass FoilDigestSHA512Class;
/* Abstract types */
GType foil_digest_get_type(void);
GType foil_digest_md5_get_type(void);
GType foil_digest_sha1_get_type(void);
GType foil_digest_sha256_get_type(void);
+GType foil_digest_sha512_get_type(void);
#define FOIL_TYPE_DIGEST (foil_digest_get_type())
#define FOIL_TYPE_DIGEST_MD5 (foil_digest_md5_get_type())
#define FOIL_TYPE_DIGEST_SHA1 (foil_digest_sha1_get_type())
#define FOIL_TYPE_DIGEST_SHA256 (foil_digest_sha256_get_type())
+#define FOIL_TYPE_DIGEST_SHA512 (foil_digest_sha512_get_type())
#define FOIL_DIGEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), \
FOIL_TYPE_DIGEST, FoilDigestClass))
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/libfoil/src/foil_digest_sha512.c
^
|
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2021 by Slava Monich
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2.Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING
+ * IN ANY WAY OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include "foil_digest_p.h"
+
+#define DIGEST_LENGTH (64)
+#define DIGEST_BLOCK_SIZE (128)
+
+G_DEFINE_ABSTRACT_TYPE(FoilDigestSHA512, foil_digest_sha512, FOIL_TYPE_DIGEST);
+
+/*
+ * http://www.ietf.org/rfc/rfc3447
+ *
+ * id-sha512 OBJECT IDENTIFIER ::= {
+ * joint-iso-itu-t(2) country(16) us(840) organization(1)
+ * gov(101) csor(3) nistalgorithm(4) hashalgs(2) 3
+ * }
+ * }
+ */
+static const guint8 foil_digest_sha512_digest_oid [] = {
+ 0x60, /* joint-iso-itu-t(2) country(16) */
+ 0x86, 0x48, /* us(840) */
+ 0x01, /* organization(1) */
+ 0x65, /* gov(101) */
+ 0x03, /* csor(3) */
+ 0x04, /* nistalgorithm(4) */
+ 0x02, /* hashalgs(2) */
+ 0x03 /* 3 */
+};
+
+static
+void*
+foil_digest_sha512_digest_alloc(void)
+{
+ return g_slice_alloc(DIGEST_LENGTH);
+}
+
+static
+void
+foil_digest_sha512_digest_free(
+ void* md)
+{
+ g_slice_free1(DIGEST_LENGTH, md);
+}
+
+static
+void
+foil_digest_sha512_init(
+ FoilDigestSHA512* self)
+{
+}
+
+static
+void
+foil_digest_sha512_class_init(
+ FoilDigestSHA512Class* klass)
+{
+ klass->name = "SHA512";
+ klass->size = DIGEST_LENGTH;
+ klass->block_size = DIGEST_BLOCK_SIZE;
+ FOIL_BYTES_SET(klass->oid, foil_digest_sha512_digest_oid);
+ klass->fn_digest_alloc = foil_digest_sha512_digest_alloc;
+ klass->fn_digest_free = foil_digest_sha512_digest_free;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/libfoil/src/foil_key.c
^
|
@@ -1,29 +1,31 @@
/*
- * Copyright (C) 2016-2020 by Slava Monich
+ * Copyright (C) 2016-2021 by Slava Monich <slava@monich.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING
- * IN ANY WAY OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
@@ -327,7 +329,7 @@
GError** error)
{
GBytes* bytes;
- FoilParsePos pos;
+ GUtilRange pos;
GString* buf = NULL;
FoilKey* key = NULL;
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/libfoil/src/foil_key_aes.c
^
|
@@ -37,8 +37,6 @@
#include "foil_input.h"
#include "foil_util.h"
-#include <ctype.h>
-
/* Logging */
#define GLOG_MODULE_NAME foil_log_key
#include "foil_log_p.h"
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/libfoil/src/foil_key_rsa_private.c
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2016-2019 by Slava Monich
+ * Copyright (C) 2016-2021 by Slava Monich <slava@monich.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
- * 1.Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2.Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING
- * IN ANY WAY OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
@@ -44,8 +49,6 @@
#include <gutil_strv.h>
#include <gutil_misc.h>
-#include <ctype.h>
-
/* Logging */
#define GLOG_MODULE_NAME foil_log_key
#include "foil_log_p.h"
@@ -205,12 +208,12 @@
static
gboolean
foil_key_rsa_private_parse_aid(
- FoilParsePos* pos,
+ GUtilRange* pos,
FoilBytes* oid,
FoilBytes* params)
{
guint32 len;
- FoilParsePos parse = *pos;
+ GUtilRange parse = *pos;
if (foil_asn1_parse_start_sequence(&parse, &len)) {
parse.end = parse.ptr + len;
if (foil_asn1_parse_object_id(&parse, oid)) {
@@ -248,7 +251,7 @@
const FoilBytes* data)
{
guint32 len;
- FoilParsePos pos;
+ GUtilRange pos;
foil_parse_init_data(&pos, data);
if (foil_asn1_parse_start_sequence(&pos, &len)) {
gint32 version;
@@ -290,7 +293,7 @@
static const guint8 oid_rsa_bytes[] = { ASN1_OID_RSA_BYTES };
static const FoilBytes oid_rsa = { oid_rsa_bytes, sizeof(oid_rsa_bytes) };
guint32 len;
- FoilParsePos pos;
+ GUtilRange pos;
foil_parse_init_data(&pos, data);
/* PrivateKeyInfo */
if (foil_asn1_parse_start_sequence(&pos, &len)) {
@@ -535,7 +538,7 @@
GBytes* decrypted = NULL;
guint32 len;
- FoilParsePos pos;
+ GUtilRange pos;
foil_parse_init_data(&pos, params);
if (foil_asn1_parse_start_sequence(&pos, &len)) {
FoilBytes kdf, kdf_param, alg, alg_param;
@@ -652,7 +655,7 @@
OID_PBES2, sizeof(OID_PBES2)
};
guint32 len;
- FoilParsePos pos;
+ GUtilRange pos;
foil_parse_init_bytes(&pos, bytes);
if (foil_asn1_parse_start_sequence(&pos, &len)) {
FoilBytes oid;
@@ -694,7 +697,7 @@
const guint8* start = foil_memmem(data, prefix);
if (start && data->len > (prefix->len + suffix->len)) {
GBytes* decoded;
- FoilParsePos pos;
+ GUtilRange pos;
GHashTable* headers;
/* Parse the header tags */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/libfoil/src/foil_key_rsa_public.c
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2016-2019 by Slava Monich
+ * Copyright (C) 2016-2021 by Slava Monich <slava@monich.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
- * 1.Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2.Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING
- * IN ANY WAY OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
@@ -129,7 +134,7 @@
static
gboolean
foil_key_rsa_public_parse_len(
- FoilParsePos* pos,
+ GUtilRange* pos,
guint32* len)
{
if ((pos->ptr + 4) <= pos->end) {
@@ -205,7 +210,7 @@
if (FOIL_KEY_RSA_PUBLIC_HAS_PREFIX(data->val, data->len,
rsa_public_binary_prefix)) {
guint32 len;
- FoilParsePos pos;
+ GUtilRange pos;
pos.ptr = data->val + G_N_ELEMENTS(rsa_public_binary_prefix);
pos.end = data->val + data->len;
if (foil_key_rsa_public_parse_len(&pos, &len) &&
@@ -233,7 +238,7 @@
{
gboolean ok = FALSE;
if (FOIL_KEY_RSA_PUBLIC_HAS_TEXT_PREFIX(data, ssh_rsa_text_prefix)) {
- FoilParsePos pos;
+ GUtilRange pos;
pos.ptr = data->val + G_N_ELEMENTS(ssh_rsa_text_prefix);
pos.end = data->val + data->len;
if (pos.ptr < pos.end && isspace(*pos.ptr)) {
@@ -269,7 +274,7 @@
const FoilBytes* bytes)
{
guint32 len;
- FoilParsePos pos;
+ GUtilRange pos;
foil_parse_init_data(&pos, bytes);
if (foil_asn1_parse_start_sequence(&pos, &len)) {
pos.end = pos.ptr + len;
@@ -326,10 +331,10 @@
static const FoilBytes oid_rsa = { oid_rsa_bytes, sizeof(oid_rsa_bytes) };
gboolean ok = FALSE;
guint32 len;
- FoilParsePos pos;
+ GUtilRange pos;
foil_parse_init_data(&pos, data);
if (foil_asn1_parse_start_sequence(&pos, &len)) {
- FoilParsePos aid;
+ GUtilRange aid;
pos.end = pos.ptr + len;
aid = pos;
/* Check AlgorithmIdentifier */
@@ -356,7 +361,7 @@
{
gboolean ok = FALSE;
if (FOIL_KEY_RSA_PUBLIC_HAS_TEXT_PREFIX(data, rsa_public_pkcs8_prefix)) {
- FoilParsePos pos;
+ GUtilRange pos;
pos.ptr = data->val + G_N_ELEMENTS(rsa_public_pkcs8_prefix);
pos.end = data->val + data->len;
if (foil_parse_skip_to_next_line(&pos, TRUE) && (pos.ptr < pos.end) &&
@@ -391,7 +396,7 @@
{
gboolean ok = FALSE;
if (FOIL_KEY_RSA_PUBLIC_HAS_TEXT_PREFIX(data, rsa_public_rfc4716_prefix)) {
- FoilParsePos pos;
+ GUtilRange pos;
pos.ptr = data->val + G_N_ELEMENTS(rsa_public_rfc4716_prefix);
pos.end = data->val + data->len;
if (foil_parse_skip_to_next_line(&pos, TRUE)) {
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/libfoil/src/foil_util.c
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2016-2019 by Slava Monich
+ * Copyright (C) 2016-2021 by Slava Monich <slava@monich.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
- * 1.Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2.Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING
- * IN ANY WAY OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
@@ -168,7 +173,7 @@
gsize
foil_parse_init_data(
- FoilParsePos* pos,
+ GUtilRange* pos,
const FoilBytes* data)
{
if (data) {
@@ -182,7 +187,7 @@
gsize
foil_parse_init_bytes(
- FoilParsePos* pos,
+ GUtilRange* pos,
GBytes* bytes)
{
if (bytes) {
@@ -198,7 +203,7 @@
gsize
foil_parse_init_string(
- FoilParsePos* pos,
+ GUtilRange* pos,
const char* str)
{
if (pos) {
@@ -216,7 +221,7 @@
void
foil_parse_skip_spaces(
- FoilParsePos* pos)
+ GUtilRange* pos)
{
while (pos->ptr < pos->end && isspace(pos->ptr[0])) {
pos->ptr++;
@@ -226,7 +231,7 @@
static
char
foil_parse_skip_to_next_line2(
- FoilParsePos* pos)
+ GUtilRange* pos)
{
char last = 0;
while (pos->ptr < pos->end && *pos->ptr != '\r' && *pos->ptr != '\n') {
@@ -241,7 +246,7 @@
gboolean
foil_parse_skip_to_next_line(
- FoilParsePos* pos,
+ GUtilRange* pos,
gboolean continued)
{
char last = foil_parse_skip_to_next_line2(pos);
@@ -255,7 +260,7 @@
gboolean
foil_parse_skip_bytes(
- FoilParsePos* pos,
+ GUtilRange* pos,
const FoilBytes* bytes)
{
if (pos->end >= pos->ptr + bytes->len &&
@@ -269,7 +274,7 @@
static
char
foil_parse_read_line2(
- FoilParsePos* pos,
+ GUtilRange* pos,
GString* buf,
gboolean skip_spaces)
{
@@ -294,7 +299,7 @@
static
gsize
foil_parse_read_line(
- FoilParsePos* pos,
+ GUtilRange* pos,
GString* buf)
{
char last;
@@ -312,7 +317,7 @@
static
gsize
foil_parse_read_tag_line(
- FoilParsePos* pos,
+ GUtilRange* pos,
GString* buf)
{
/* Skip empty lines */
@@ -337,7 +342,7 @@
GHashTable*
foil_parse_headers(
- FoilParsePos* pos,
+ GUtilRange* pos,
GString* buf)
{
GHashTable* headers = NULL;
@@ -448,7 +453,7 @@
GBytes*
foil_parse_base64(
- FoilParsePos* pos,
+ GUtilRange* pos,
guint flags)
{
FoilInput* mem = foil_input_mem_new_static(pos->ptr, pos->end - pos->ptr);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/libfoil/src/foil_util_p.h
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2016-2019 by Slava Monich
+ * Copyright (C) 2016-2021 by Slava Monich <slava@monich.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
- * 1.Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2.Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING
- * IN ANY WAY OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
@@ -56,27 +61,27 @@
gsize
foil_parse_init_data(
- FoilParsePos* pos,
+ GUtilRange* pos,
const FoilBytes* data);
gsize
foil_parse_init_bytes(
- FoilParsePos* pos,
+ GUtilRange* pos,
GBytes* bytes);
gsize
foil_parse_init_string(
- FoilParsePos* pos,
+ GUtilRange* pos,
const char* str);
gboolean
foil_parse_skip_to_next_line(
- FoilParsePos* pos,
+ GUtilRange* pos,
gboolean continued);
GHashTable*
foil_parse_headers(
- FoilParsePos* pos,
+ GUtilRange* pos,
GString* buf);
char*
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/libfoil/src/openssl/foil_openssl_digest_sha512.c
^
|
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2021 by Slava Monich
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2.Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING
+ * IN ANY WAY OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation
+ * are those of the authors and should not be interpreted as representing
+ * any official policies, either expressed or implied.
+ */
+
+#include "foil_digest_p.h"
+
+#include <openssl/sha.h>
+
+/* Logging */
+#define GLOG_MODULE_NAME foil_log_digest
+#include "foil_log_p.h"
+
+typedef FoilDigestSHA512Class FoilOpensslDigestSHA512Class;
+typedef struct foil_openssl_digest_sha512 {
+ FoilDigestSHA512 sha512;
+ SHA512_CTX ctx;
+} FoilOpensslDigestSHA512;
+
+G_DEFINE_TYPE(FoilOpensslDigestSHA512, foil_openssl_digest_sha512, \
+ FOIL_TYPE_DIGEST_SHA512)
+#define FOIL_OPENSSL_DIGEST_SHA512(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, \
+ FOIL_DIGEST_SHA512, FoilOpensslDigestSHA512))
+
+GType
+foil_impl_digest_sha512_get_type()
+{
+ return foil_openssl_digest_sha512_get_type();
+}
+
+static
+void
+foil_openssl_digest_sha512_copy(
+ FoilDigest* digest,
+ FoilDigest* source)
+{
+ FoilOpensslDigestSHA512* self = FOIL_OPENSSL_DIGEST_SHA512(digest);
+ FoilOpensslDigestSHA512* other = FOIL_OPENSSL_DIGEST_SHA512(source);
+ self->ctx = other->ctx;
+}
+
+static
+void
+foil_openssl_digest_sha512_update(
+ FoilDigest* digest,
+ const void* data,
+ size_t size)
+{
+ FoilOpensslDigestSHA512* self = FOIL_OPENSSL_DIGEST_SHA512(digest);
+ SHA512_Update(&self->ctx, data, size);
+}
+
+static
+void
+foil_openssl_digest_sha512_finish(
+ FoilDigest* digest,
+ void* md)
+{
+ FoilOpensslDigestSHA512* self = FOIL_OPENSSL_DIGEST_SHA512(digest);
+ if (G_LIKELY(md)) {
+ SHA512_Final(md, &self->ctx);
+ } else {
+ memset(&self->ctx, 0, sizeof(self->ctx));
+ }
+}
+
+static
+void
+foil_openssl_digest_sha512_digest(
+ const void* data,
+ size_t size,
+ void* digest)
+{
+ SHA512(data, size, digest);
+}
+
+static
+void
+foil_openssl_digest_sha512_init(
+ FoilOpensslDigestSHA512* self)
+{
+ SHA512_Init(&self->ctx);
+}
+
+static
+void
+foil_openssl_digest_sha512_class_init(
+ FoilOpensslDigestSHA512Class* klass)
+{
+ GASSERT(klass->size == SHA512_DIGEST_LENGTH);
+ klass->fn_copy = foil_openssl_digest_sha512_copy;
+ klass->fn_digest = foil_openssl_digest_sha512_digest;
+ klass->fn_update = foil_openssl_digest_sha512_update;
+ klass->fn_finish = foil_openssl_digest_sha512_finish;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/libfoilmsg/README
^
|
@@ -34,13 +34,18 @@
can be followed by (relatively) small amount of garbage.
The format tag is 1 for AES in CBC mode, 2 for AES in CFB mode.
-signature is the hash of encryptedData part, encrypted with the
-sender's private key.
-The format tag is 1 for MD-5 hash + 16 bytes of random padding,
-encrypted with RSA private key. When signature is being verified,
-padding is (obviously) ignored. Since RSA iself inflates the data,
-padding doesn't actually increase the size of the signature part,
-but kills any correlation with the input data.
+signature is the hash of encryptedData part + the same amount of
+random padding (16 bytes for MD-5, 20 bytes for SHA-1 and so on),
+encrypted with sender's RSA private key. Signature tag specifies
+the hash algorithm:
+1 for MD-5
+2 for SHA-1
+3 for SHA-256
+4 for SHA-512
+When signature is being verified, the padding is (obviously) ignored.
+Since RSA iself inflates the data, padding normally doesn't increase
+the size of the signature part, but does kill any correlation with
+the input data.
EncryptedKeys
=============
@@ -67,9 +72,9 @@
The exact format depends on the block cipher algorithm and is
specified by keyFormat.
-keyFormat is 1 for AES 128 (16 bytes key + 16 bytes IV)
-keyFormat is 2 for AES 192 (24 bytes key + 16 bytes IV)
-keyFormat is 3 for AES 256 (32 bytes key + 16 bytes IV)
+keyFormat is 1 for AES-128 (16 bytes key + 16 bytes IV)
+keyFormat is 2 for AES-192 (24 bytes key + 16 bytes IV)
+keyFormat is 3 for AES-256 (32 bytes key + 16 bytes IV)
Since RSA iself inflates the data, the key size doesn't actually
increase the size of the encrypted key.
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/libfoilmsg/include/foilmsg.h
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2020 by Slava Monich
+ * Copyright (C) 2016-2021 by Slava Monich
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -60,6 +60,7 @@
#define FOILMSG_SIGNATURE_FORMAT_MD5_RSA (1)
#define FOILMSG_SIGNATURE_FORMAT_SHA1_RSA (2)
#define FOILMSG_SIGNATURE_FORMAT_SHA256_RSA (3)
+#define FOILMSG_SIGNATURE_FORMAT_SHA512_RSA (4)
/* N.B. Must be freed with foilmsg_info_free */
typedef struct foilmsg_info {
@@ -108,7 +109,8 @@
typedef enum foilmsg_signature {
FOILMSG_SIGNATURE_MD5_RSA,
FOILMSG_SIGNATURE_SHA1_RSA,
- FOILMSG_SIGNATURE_SHA256_RSA
+ FOILMSG_SIGNATURE_SHA256_RSA,
+ FOILMSG_SIGNATURE_SHA512_RSA
} FOILMSG_SIGNATURE;
#define FOILMSG_KEY_TYPE_DEFAULT (FOILMSG_KEY_AES_128)
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/libfoilmsg/src/foilmsg_decrypt.c
^
|
@@ -1,29 +1,31 @@
/*
- * Copyright (C) 2016-2020 by Slava Monich
+ * Copyright (C) 2016-2021 by Slava Monich <slava@monich.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
- * 1.Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2.Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING
- * IN ANY WAY OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
@@ -144,12 +146,12 @@
static
gboolean
foilmsg_decode_tagged_data(
- FoilParsePos* pos,
+ GUtilRange* pos,
FoilMsgTaggedData* block)
{
guint32 len;
if (foil_asn1_parse_start_sequence(pos, &len)) {
- FoilParsePos seq;
+ GUtilRange seq;
seq.ptr = pos->ptr;
seq.end = pos->ptr + len;
if (foil_asn1_parse_int32(&seq, &block->tag) &&
@@ -186,13 +188,13 @@
static
FoilMsgInfo*
foilmsg_parse_encrypted_keys(
- FoilParsePos* pos)
+ GUtilRange* pos)
{
FoilMsgInfo* msg = NULL;
guint32 len;
if (foil_asn1_parse_start_sequence(pos, &len)) {
gint32 key_format;
- FoilParsePos seq;
+ GUtilRange seq;
seq.ptr = pos->ptr;
seq.end = pos->ptr + len;
if (foil_asn1_parse_int32(&seq, &key_format)) {
@@ -200,7 +202,7 @@
GSList* keys = NULL;
guint i, nkeys = 0;
while (foil_asn1_parse_start_sequence(&seq, &len)) {
- FoilParsePos seq2;
+ GUtilRange seq2;
seq2.ptr = seq.ptr;
seq2.end = seq.ptr + len;
key = g_slice_new(FoilMsgEncryptKey);
@@ -287,6 +289,10 @@
dec->sig_digest_type = FOIL_DIGEST_SHA256;
dec->sig_cipher_type = FOIL_CIPHER_RSA_DECRYPT;
break;
+ case FOILMSG_SIGNATURE_FORMAT_SHA512_RSA:
+ dec->sig_digest_type = FOIL_DIGEST_SHA512;
+ dec->sig_cipher_type = FOIL_CIPHER_RSA_DECRYPT;
+ break;
default:
return FALSE;
}
@@ -357,7 +363,7 @@
const FoilBytes* bytes)
{
guint32 len;
- FoilParsePos pos;
+ GUtilRange pos;
pos.ptr = bytes->val;
pos.end = pos.ptr + bytes->len;
if (foil_asn1_parse_start_sequence(&pos, &len)) {
@@ -617,7 +623,7 @@
{
GBytes* bytes = NULL;
if (G_LIKELY(data)) {
- FoilParsePos pos;
+ GUtilRange pos;
pos.ptr = data->val;
pos.end = pos.ptr + data->len;
foil_parse_skip_spaces(&pos);
@@ -653,7 +659,7 @@
{
FoilMsg* ret = NULL;
if (G_LIKELY(recipient) && G_LIKELY(text)) {
- FoilParsePos pos;
+ GUtilRange pos;
pos.ptr = text->val;
pos.end = pos.ptr + text->len;
foil_parse_skip_spaces(&pos);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/libfoilmsg/src/foilmsg_encrypt.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2020 by Slava Monich
+ * Copyright (C) 2016-2021 by Slava Monich
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -384,6 +384,10 @@
type = FOIL_DIGEST_SHA256;
*tag = FOILMSG_SIGNATURE_FORMAT_SHA256_RSA;
break;
+ case FOILMSG_SIGNATURE_SHA512_RSA:
+ type = FOIL_DIGEST_SHA512;
+ *tag = FOILMSG_SIGNATURE_FORMAT_SHA512_RSA;
+ break;
}
return foil_digest_new(type);
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/rpm/foil.spec
^
|
@@ -1,5 +1,5 @@
Name: libfoil
-Version: 1.0.21
+Version: 1.0.23
Release: 0
Summary: Yet another glib-style crypto API
Group: Development/Libraries
@@ -10,12 +10,14 @@
%define glib_version 2.36
%define libglibutil_version 1.0.24
+%define libglibutil_build_version 1.0.54
BuildRequires: file-devel
+BuildRequires: pkgconfig
BuildRequires: pkgconfig(openssl)
BuildRequires: pkgconfig(libpng)
BuildRequires: pkgconfig(glib-2.0) >= %{glib_version}
-BuildRequires: pkgconfig(libglibutil) >= %{libglibutil_version}
+BuildRequires: pkgconfig(libglibutil) >= %{libglibutil_build_version}
Requires: glib2 >= %{glib_version}
Requires: libglibutil >= %{libglibutil_version}
Requires(post): /sbin/ldconfig
@@ -27,7 +29,7 @@
%package devel
Summary: Development library for %{name}
Requires: %{name} = %{version}
-Requires: pkgconfig
+Requires: pkgconfig(libglibutil) >= %{libglibutil_build_version}
%description devel
This package contains the development library for %{name}.
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/test/libfoil/test_basic/test_basic.c
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2016-2019 by Slava Monich
+ * Copyright (C) 2016-2021 by Slava Monich <slava@monich.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
- * 1.Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2.Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING
- * IN ANY WAY OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation
* are those of the authors and should not be interpreted as representing
@@ -170,7 +175,7 @@
test_skip(
void)
{
- FoilParsePos pos;
+ GUtilRange pos;
static const FoilBytes bytes = { (const void*)"xyz", 3 };
/* Test NULL resistance */
@@ -221,7 +226,7 @@
const char* value,
const char* expected)
{
- FoilParsePos pos;
+ GUtilRange pos;
GHashTable* headers;
char* header = foil_format_header(tag, value);
@@ -314,7 +319,7 @@
void)
{
GString* buf = g_string_new(NULL);
- FoilParsePos pos;
+ GUtilRange pos;
GHashTable* headers;
foil_parse_init_string(&pos, "");
@@ -345,7 +350,7 @@
static const guint8 a[] = { 0x01 };
static const guint8 b[] = { 0x01, 0x02 };
static const guint8 c[] = { 0x01, 0x02, 0x03 };
- FoilParsePos pos;
+ GUtilRange pos;
GBytes* bytes;
foil_parse_init_string(&pos, "AQ");
@@ -434,7 +439,7 @@
FoilInput* in;
guint32 len;
gboolean def;
- FoilParsePos pos;
+ GUtilRange pos;
pos.ptr = pos.end = len_short;
in = foil_input_mem_new(NULL);
@@ -626,7 +631,7 @@
const FoilBytes bytes1 = { seq1 + 2, sizeof(seq1) - 2 };
const FoilBytes bytes2 = { seq2 + 4, sizeof(seq2) - 4 };
const FoilBytes* data1 = &bytes1;
- FoilParsePos pos;
+ GUtilRange pos;
guint32 len;
FoilInput* in0 = foil_input_mem_new(NULL);
FoilInput* in1 = foil_input_mem_new_static(seq1, sizeof(seq1));
@@ -747,7 +752,7 @@
guint i;
guint32 len;
- FoilParsePos pos;
+ GUtilRange pos;
static const guint8 not_bit_string[] = { 0x00 };
static const guint8 broken_bit_string[] = { 0x03, 0x82, 0x01 };
static const guint8 broken_bit_string2[] = { 0x03, 0x00 };
@@ -959,7 +964,7 @@
guint i;
for (i=0; i<G_N_ELEMENTS(subtest); i++) {
- FoilParsePos pos, pos2;
+ GUtilRange pos, pos2;
FoilBytes bytes;
gboolean expected = subtest[i].good;
pos.ptr = subtest[i].data;
@@ -1021,7 +1026,7 @@
gsize length;
FoilInput* in = foil_input_mem_new_static(subtest->data, subtest->len);
char* str = foil_asn1_read_ia5_string(in, -1, &length);
- FoilParsePos pos, pos2;
+ GUtilRange pos, pos2;
FoilBytes bytes;
gboolean expected = subtest->good;
pos.ptr = subtest->data;
@@ -1120,7 +1125,7 @@
const struct asn1_int_test* subtest = number + i;
FoilInput* in1 = foil_input_mem_new_static(subtest->data, subtest->len);
FoilInput* in2 = foil_input_mem_new_static(subtest->data, subtest->len);
- FoilParsePos pos, pos1;
+ GUtilRange pos, pos1;
gint32 value;
if (subtest->ok) {
GBytes* enc1 = foil_asn1_encode_integer_value(subtest->value);
@@ -1158,6 +1163,65 @@
}
}
+static
+void
+test_asn1_tag(
+ void)
+{
+ static const guint8 x22 [] = { 0x22 };
+ static const guint8 x5f31 [] = { 0x5f, 0x31 };
+ static const guint8 x5f817f [] = { 0x5f, 0x81, 0x7f };
+ static const guint8 x5f00 [] = { 0x5f, 0x00 }; /* Zero byte */
+ static const guint8 x5f81 [] = { 0x5f, 0x81 }; /* Too short */
+ static const guint8 x7fffffffff7f [] =
+ { 0x7f, 0xff, 0xff, 0xff, 0xff, 0x7f }; /* Too many bits */
+ static const guint8 x5f818181818181 [] =
+ { 0x5f, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81 }; /* Too long */
+ static const struct asn1_tag_test {
+ gboolean ok;
+ guint8 id;
+ guint tag;
+ FoilBytes data;
+ } tests [] = {
+ { TRUE, 0x22, 0x02, { TEST_ARRAY_AND_SIZE(x22) } },
+ { TRUE, 0x5f, 0x31, { TEST_ARRAY_AND_SIZE(x5f31) } },
+ { TRUE, 0x5f, 0xff, { TEST_ARRAY_AND_SIZE(x5f817f) } },
+ { FALSE, 0, 0, { TEST_ARRAY_AND_SIZE(x5f00) } },
+ { FALSE, 0, 0, { TEST_ARRAY_AND_SIZE(x5f81) } },
+ { FALSE, 0, 0, { TEST_ARRAY_AND_SIZE(x7fffffffff7f) } },
+ { FALSE, 0, 0, { TEST_ARRAY_AND_SIZE(x5f818181818181) } }
+ };
+
+ GUtilRange pos;
+ gsize i;
+
+ memset(&pos, 0, sizeof(pos));
+ g_assert(!foil_asn1_parse_tag(&pos, NULL, NULL));
+ for (i = 0; i < G_N_ELEMENTS(tests); i++) {
+ const FoilBytes* data = &tests[i].data;
+ gboolean ok = tests[i].ok;
+ guint8 id = 0;
+ guint tag = 0;
+
+ pos.ptr = data->val;
+ pos.end = pos.ptr + data->len;
+ g_assert(foil_asn1_parse_tag(&pos, NULL, NULL) == ok);
+
+ pos.ptr = data->val;
+ pos.end = pos.ptr + data->len;
+ g_assert(foil_asn1_parse_tag(&pos, &id, &tag) == ok);
+ if (ok) {
+ g_assert_cmpuint(id, == ,tests[i].id);
+ g_assert_cmpuint(tag, == ,tests[i].tag);
+ g_assert(pos.ptr == pos.end);
+ } else {
+ g_assert(pos.ptr == data->val);
+ g_assert_cmpuint(id, == ,0);
+ g_assert_cmpuint(tag, == ,0);
+ }
+ }
+}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/test/libfoil/test_cavp_aes/test_cavp_aes.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2019 by Slava Monich
+ * Copyright (C) 2016-2021 by Slava Monich
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -47,7 +47,8 @@
#define TEST_IV (0x04)
#define TEST_PLAINTEXT (0x08)
#define TEST_CIPHERTEXT (0x10)
-#define TEST_ALL (0x1f)
+#define TEST_REQUIRED (TEST_COUNT|TEST_KEY|TEST_PLAINTEXT|TEST_CIPHERTEXT)
+#define TEST_ALL (TEST_REQUIRED|TEST_IV)
typedef enum aes_test_section {
TEST_SECTION_NONE = -1,
@@ -91,8 +92,7 @@
g_string_truncate(str, 0);
while ((c = fgetc(f)) != EOF) {
if (c == '\r' || c == '\n') {
- while ((c = fgetc(f)) != EOF && (c == '\r' || c == '\n'));
- if (c != EOF) ungetc(c, f);
+ if (c == '\r') c = fgetc(f);
break;
}
if (!isspace(c)) g_string_append_c(str, c);
@@ -155,6 +155,26 @@
}
static
+void
+test_append(
+ Tests* tests,
+ TestSection section,
+ const Test* test)
+{
+ Test* t = g_new(Test, 1);
+ *t = *test;
+ if (!t->iv) {
+ /* Default IV (16 bytes) */
+ static const guint8 iv[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+ };
+ t->iv = g_bytes_new_static(iv, sizeof(iv));
+ }
+ tests->tests[section] = g_slist_append(tests->tests[section], t);
+}
+
+static
gboolean
test_parse_file(
const char* fname,
@@ -178,16 +198,22 @@
flags = 0;
} else if (section != TEST_SECTION_NONE) {
flags |= test_parse_line(line, &test);
- if ((flags & TEST_ALL) == TEST_ALL) {
- Test* t = g_new0(Test, 1);
- *t = test;
- tests->tests[section] = g_slist_append(
- tests->tests[section], t);
+ if ((flags & TEST_ALL) == TEST_ALL ||
+ (((flags & TEST_REQUIRED) == TEST_REQUIRED) && !line[0])) {
+ test_append(tests, section, &test);
flags = 0;
memset(&test, 0, sizeof(test));
}
}
}
+ if ((flags & TEST_REQUIRED) == TEST_REQUIRED) {
+ test_append(tests, section, &test);
+ } else {
+ g_assert(!test.key);
+ g_assert(!test.iv);
+ g_assert(!test.plaintext);
+ g_assert(!test.ciphertext);
+ }
g_string_free(str, TRUE);
fclose(f);
return TRUE;
@@ -362,6 +388,8 @@
{
guint i;
g_test_init(&argc, &argv, NULL);
+ gutil_log_default.level = g_test_verbose() ?
+ GLOG_LEVEL_VERBOSE : GLOG_LEVEL_NONE;
for (i = 0; i < G_N_ELEMENTS(ecb_tests); i++) {
const char* fname = ecb_tests[i];
char* name = g_strconcat(TEST_PREFIX, fname, NULL);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/test/libfoil/test_digest/test_digest.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2018 by Slava Monich
+ * Copyright (C) 2016-2021 by Slava Monich
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -11,6 +11,9 @@
* notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@@ -114,7 +117,7 @@
0x4F,0x46,0x04,0x52
};
-/* SHA256 examples from http://www.ietf.org/rfc/rfc4634 */
+/* SHA256 examples from https://www.ietf.org/rfc/rfc4634 */
#define SHA256_TEST1 "abc"
#define SHA256_TEST2a "abcdbcdecdefdefgefghfghighij"
@@ -150,6 +153,65 @@
0x35,0xF2,0x5A,0xB5,0x56,0x2B,0xFB,0xB5
};
+/* SHA512 examples from https://tools.ietf.org/html/rfc6234 */
+
+#define SHA512_TEST1 "abc"
+#define SHA512_TEST2_1 "abcdbcdecdefdefgefghfghighij" \
+ "hijkijkljklmklmnlmnomnopnopq"
+#define SHA512_TEST2a "abcdefghbcdefghicdefghijdefg" \
+ "hijkefghijklfghijklmghijklmn"
+#define SHA512_TEST2b "hijklmnoijklmnopjklmnopqklmn" \
+ "opqrlmnopqrsmnopqrstnopqrstu"
+#define SHA512_TEST2 SHA512_TEST2a SHA512_TEST2b
+#define SHA512_TEST3 "a"
+#define SHA512_TEST4a "01234567012345670123456701234567"
+#define SHA512_TEST4b "01234567012345670123456701234567"
+#define SHA512_TEST4 SHA512_TEST4a SHA512_TEST4b
+
+static const guint8 test_sha512_data1[] = {
+ 0xDD,0xAF,0x35,0xA1,0x93,0x61,0x7A,0xBA,
+ 0xCC,0x41,0x73,0x49,0xAE,0x20,0x41,0x31,
+ 0x12,0xE6,0xFA,0x4E,0x89,0xA9,0x7E,0xA2,
+ 0x0A,0x9E,0xEE,0xE6,0x4B,0x55,0xD3,0x9A,
+ 0x21,0x92,0x99,0x2A,0x27,0x4F,0xC1,0xA8,
+ 0x36,0xBA,0x3C,0x23,0xA3,0xFE,0xEB,0xBD,
+ 0x45,0x4D,0x44,0x23,0x64,0x3C,0xE8,0x0E,
+ 0x2A,0x9A,0xC9,0x4F,0xA5,0x4C,0xA4,0x9F
+};
+
+static const guint8 test_sha512_data2[] = {
+ 0x8E,0x95,0x9B,0x75,0xDA,0xE3,0x13,0xDA,
+ 0x8C,0xF4,0xF7,0x28,0x14,0xFC,0x14,0x3F,
+ 0x8F,0x77,0x79,0xC6,0xEB,0x9F,0x7F,0xA1,
+ 0x72,0x99,0xAE,0xAD,0xB6,0x88,0x90,0x18,
+ 0x50,0x1D,0x28,0x9E,0x49,0x00,0xF7,0xE4,
+ 0x33,0x1B,0x99,0xDE,0xC4,0xB5,0x43,0x3A,
+ 0xC7,0xD3,0x29,0xEE,0xB6,0xDD,0x26,0x54,
+ 0x5E,0x96,0xE5,0x5B,0x87,0x4B,0xE9,0x09
+};
+
+static const guint8 test_sha512_data3[] = {
+ 0xE7,0x18,0x48,0x3D,0x0C,0xE7,0x69,0x64,
+ 0x4E,0x2E,0x42,0xC7,0xBC,0x15,0xB4,0x63,
+ 0x8E,0x1F,0x98,0xB1,0x3B,0x20,0x44,0x28,
+ 0x56,0x32,0xA8,0x03,0xAF,0xA9,0x73,0xEB,
+ 0xDE,0x0F,0xF2,0x44,0x87,0x7E,0xA6,0x0A,
+ 0x4C,0xB0,0x43,0x2C,0xE5,0x77,0xC3,0x1B,
+ 0xEB,0x00,0x9C,0x5C,0x2C,0x49,0xAA,0x2E,
+ 0x4E,0xAD,0xB2,0x17,0xAD,0x8C,0xC0,0x9B
+};
+
+static const guint8 test_sha512_data4[] = {
+ 0x89,0xD0,0x5B,0xA6,0x32,0xC6,0x99,0xC3,
+ 0x12,0x31,0xDE,0xD4,0xFF,0xC1,0x27,0xD5,
+ 0xA8,0x94,0xDA,0xD4,0x12,0xC0,0xE0,0x24,
+ 0xDB,0x87,0x2D,0x1A,0xBD,0x2B,0xA8,0x14,
+ 0x1A,0x0F,0x85,0x07,0x2A,0x9B,0xE1,0xE2,
+ 0xAA,0x04,0xCF,0x33,0xC7,0x65,0xCB,0x51,
+ 0x08,0x13,0xA3,0x9C,0xD5,0xA8,0x4C,0x4A,
+ 0xCA,0xA6,0x4D,0x3F,0x3F,0xB7,0xBA,0xE9
+};
+
static
void
test_basic(
@@ -177,10 +239,11 @@
g_assert(!foil_digest_bytes(0, NULL));
g_assert(!foil_digest_bytes(0, bytes));
g_assert(!foil_digest_type_block_size(FOIL_TYPE_DIGEST));
- g_assert(foil_digest_type_block_size(FOIL_DIGEST_MD5) == 64u);
- g_assert(foil_digest_type_block_size(FOIL_DIGEST_SHA1) == 64u);
- g_assert(foil_digest_type_block_size(FOIL_DIGEST_SHA256) == 64u);
- g_assert(foil_digest_block_size(md5) == 64u);
+ g_assert_cmpuint(foil_digest_type_block_size(FOIL_DIGEST_MD5), == ,64);
+ g_assert_cmpuint(foil_digest_type_block_size(FOIL_DIGEST_SHA1), == ,64);
+ g_assert_cmpuint(foil_digest_type_block_size(FOIL_DIGEST_SHA256), == ,64);
+ g_assert_cmpuint(foil_digest_type_block_size(FOIL_DIGEST_SHA512), == ,128);
+ g_assert_cmpuint(foil_digest_block_size(md5), == ,64);
foil_digest_update(NULL, NULL, 0);
foil_digest_update_bytes(NULL, NULL);
foil_digest_update_bytes(md5, NULL);
@@ -291,6 +354,20 @@
foil_digest_unref(d1);
foil_digest_unref(d2);
+
+ /* SHA512 */
+ d1 = foil_digest_new_sha512();
+ d2 = foil_digest_new_sha512();
+ foil_digest_update(d1, SHA512_TEST1, strlen(SHA512_TEST1));
+ g_assert(foil_digest_copy(d1, d2));
+ foil_digest_update(d1, SHA512_TEST2, strlen(SHA512_TEST2));
+ b1 = foil_digest_finish(d1);
+ g_assert(g_bytes_get_size(b1) == sizeof(test_sha512_data2));
+ g_assert(!memcmp(g_bytes_get_data(b1, NULL), test_sha512_data2,
+ sizeof(test_sha512_data2)));
+
+ foil_digest_unref(d1);
+ foil_digest_unref(d2);
}
static
@@ -349,6 +426,7 @@
#define TEST_MD5(i,n) TEST_(MD5,md5,i,n)
#define TEST_SHA1(i,n) TEST_(SHA1,sha1,i,n)
#define TEST_SHA256(i,n) TEST_(SHA256,sha256,i,n)
+#define TEST_SHA512(i,n) TEST_(SHA512,sha512,i,n)
static const TestDigest tests[] = {
{ TEST_NAME("Basic"), test_basic },
@@ -371,7 +449,12 @@
TEST_SHA256(1,1),
TEST_SHA256(2,1),
TEST_SHA256(3,1000000),
- TEST_SHA256(4,10)
+ TEST_SHA256(4,10),
+ /* SHA512 */
+ TEST_SHA512(1,1),
+ TEST_SHA512(2,1),
+ TEST_SHA512(3,1000000),
+ TEST_SHA512(4,10)
};
int main(int argc, char* argv[])
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/test/libfoilmsg/test_foilmsg/test_foilmsg.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2020 by Slava Monich
+ * Copyright (C) 2016-2021 by Slava Monich
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -580,6 +580,11 @@
FOILMSG_CIPHER_AES_CBC, FOILMSG_SIGNATURE_SHA256_RSA
};
+static const FoilMsgEncryptOptions options_aes_256_sha512_rsa = {
+ FOILMSG_KEY_AES_256, FOILMSG_FLAG_ENCRYPT_FOR_SELF,
+ FOILMSG_CIPHER_AES_CBC, FOILMSG_SIGNATURE_SHA512_RSA
+};
+
static const FoilMsgEncryptOptions options_aes_256_invalid_sig_alg = {
FOILMSG_KEY_AES_256, FOILMSG_FLAG_ENCRYPT_FOR_SELF,
FOILMSG_CIPHER_AES_CBC, (FOILMSG_SIGNATURE)-1
@@ -657,6 +662,11 @@
{ "rsa-768", "rsa-768.pub", "rsa-1024", "rsa-1024.pub" },
&options_aes_256_sha256_rsa
},{
+ TEST_("Signature/SHA512"), test_foilmsg_text,
+ "Test of SHA512/RSA signature",
+ { "rsa-768", "rsa-768.pub", "rsa-1024", "rsa-1024.pub" },
+ &options_aes_256_sha512_rsa
+ },{
TEST_("Signature/Invalid"), test_foilmsg_text,
"Test of invalid signature algorithm",
{ "rsa-768", "rsa-768.pub", "rsa-1024", "rsa-1024.pub" },
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/tools/foilmsg/foilmsg.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2020 by Slava Monich
+ * Copyright (C) 2016-2021 by Slava Monich
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -100,6 +100,8 @@
return " (SHA1-RSA)";
case FOILMSG_SIGNATURE_FORMAT_SHA256_RSA:
return " (SHA256-RSA)";
+ case FOILMSG_SIGNATURE_FORMAT_SHA512_RSA:
+ return " (SHA512-RSA)";
default:
return "";
}
@@ -436,7 +438,7 @@
{ "self", 'S', 0, G_OPTION_ARG_NONE, &for_self,
"Encrypt to self and the recipient", NULL },
{ "digest", 'D', 0, G_OPTION_ARG_STRING, &digest,
- "Signature digest (MD5, SHA1 or SHA256) [MD5]", "DIGEST" },
+ "Signature digest (MD5, SHA1, SHA256 or SHA512) [MD5]", "DIGEST" },
{ NULL }
};
GOptionEntry decrypt_entries[] = {
@@ -630,6 +632,9 @@
} else if (!g_ascii_strcasecmp(digest, "SHA256") ||
!g_ascii_strcasecmp(digest, "SHA-256")) {
opt.signature = FOILMSG_SIGNATURE_SHA256_RSA;
+ } else if (!g_ascii_strcasecmp(digest, "SHA512") ||
+ !g_ascii_strcasecmp(digest, "SHA-512")) {
+ opt.signature = FOILMSG_SIGNATURE_SHA512_RSA;
} else {
GWARN("Invalid signature digest \"%s\", using "
"the default one (MD5)", digest);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/foil/tools/foilpng/foilpng.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017-2020 by Slava Monich
+ * Copyright (C) 2017-2021 by Slava Monich
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -436,7 +436,7 @@
{ "self", 'S', 0, G_OPTION_ARG_NONE, &for_self,
"Encrypt to self and the recipient", NULL },
{ "digest", 'D', 0, G_OPTION_ARG_STRING, &digest,
- "Signature digest (MD5, SHA1 or SHA256) [MD5]", "DIGEST" },
+ "Signature digest (MD5, SHA1, SHA256 or SHA512) [MD5]", "DIGEST" },
{ NULL }
};
const char* summary =
@@ -657,6 +657,9 @@
} else if (!g_ascii_strcasecmp(digest, "SHA256") ||
!g_ascii_strcasecmp(digest, "SHA-256")) {
opt.signature = FOILMSG_SIGNATURE_SHA256_RSA;
+ } else if (!g_ascii_strcasecmp(digest, "SHA512") ||
+ !g_ascii_strcasecmp(digest, "SHA-512")) {
+ opt.signature = FOILMSG_SIGNATURE_SHA512_RSA;
} else {
GWARN("Invalid signature digest \"%s\", using "
"the default one (MD5)", digest);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/harbour-lib/include/HarbourProcessState.h
^
|
@@ -44,7 +44,7 @@
Q_OBJECT
Q_DISABLE_COPY(HarbourProcessState)
Q_PROPERTY(bool jailedApp READ isJailedApp CONSTANT)
- Q_PROPERTY(bool provileged READ isPrivileged CONSTANT)
+ Q_PROPERTY(bool privileged READ isPrivileged CONSTANT)
public:
explicit HarbourProcessState(QObject* aParent = Q_NULLPTR);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/harbour-lib/qml/HarbourColorEditorDialog.qml
^
|
@@ -164,12 +164,9 @@
EnterKey.onClicked: hexText.focus = false
onTextChanged: {
- if (!ignoreTextUpdates && acceptableInput) {
- tmpColor = "#" + text
- ignoreTextUpdates++
- brightnessSlider.value = hueItem.getV(tmpColor)
- hueSlider.value = hueItem.getH(tmpColor)
- ignoreTextUpdates--
+ if (!ignoreTextUpdates) {
+ // acceptableInput hasn't been updated yet
+ syncTimer.restart()
}
}
@@ -179,6 +176,16 @@
}
}
+ function syncColor() {
+ if (acceptableInput) {
+ tmpColor = "#" + text
+ ignoreTextUpdates++
+ brightnessSlider.value = hueItem.getV(tmpColor)
+ hueSlider.value = hueItem.getH(tmpColor)
+ ignoreTextUpdates--
+ }
+ }
+
function updateText() {
if (!ignoreTextUpdates) {
ignoreTextUpdates++
@@ -187,6 +194,13 @@
ignoreTextUpdates--
}
}
+
+ Timer {
+ id: syncTimer
+
+ interval: 0
+ onTriggered: hexText.syncColor()
+ }
}
}
}
@@ -198,15 +212,16 @@
width: 2 * height
height: hexText.height - 2 * Theme.paddingLarge
anchors.right: parent.right
+ visible: hexText.acceptableInput
onClicked: thisDialog.accept()
Rectangle {
id: sampleItem
+ radius: Theme.paddingSmall
anchors.fill: parent
color: "#" + hexText.text
- visible: hexText.acceptableInput
layer.enabled: sample.pressed && sample.containsMouse
layer.effect: HarbourPressEffect { source: sampleItem }
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/harbour-lib/qml/HarbourColorHueItem.qml
^
|
@@ -38,6 +38,7 @@
id: thisItem
color: "black"
+
property alias brightness: mouseArea.opacity
property alias pressed: mouseArea.pressed
@@ -143,6 +144,7 @@
sourceItem: Rectangle {
width: mouseArea.width
height: mouseArea.height
+ radius: Theme.paddingSmall
gradient: Gradient {
GradientStop { position: 0.0; color: color0 }
GradientStop { position: colorStop1; color: color1 }
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/harbour-lib/src/HarbourSystemInfo.cpp
^
|
@@ -44,6 +44,7 @@
#include <QFile>
#include <QTextStream>
+#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
@@ -255,7 +256,7 @@
argv[5] = NULL;
while ((dup2(fds[1], STDOUT_FILENO) == -1) && (errno == EINTR));
execvp(argv[0], (char**)argv);
- exit(1);
+ abort();
}
close(fds[1]);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/libglibutil/.gitignore
^
|
@@ -4,6 +4,7 @@
test/coverage/full.gcov
test/coverage/libglibutil.gcov
test/coverage/results
+debian/.debhelper
debian/files
debian/libglibutil-dev.debhelper.log
debian/libglibutil-dev.install
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/libglibutil/Makefile
^
|
@@ -20,7 +20,7 @@
VERSION_MAJOR = 1
VERSION_MINOR = 0
-VERSION_RELEASE = 51
+VERSION_RELEASE = 55
# Version for pkg-config
PCVERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/libglibutil/debian/changelog
^
|
@@ -1,3 +1,32 @@
+libglibutil (1.0.55) unstable; urgency=low
+
+ * Added gutil_log_dump()
+ * Added gutil_range_init_with_bytes()
+ * Added gutil_range_has_prefix()
+ * Added gutil_range_skip_prefix()
+
+ -- Slava Monich <slava.monich@jolla.com> Sun, 23 May 2021 03:33:58 +0300
+
+libglibutil (1.0.54) unstable; urgency=low
+
+ * Added GUtilRange type
+ * Tweaked interpretation of environment variables
+
+ -- Slava Monich <slava.monich@jolla.com> Mon, 17 May 2021 16:06:25 +0300
+
+libglibutil (1.0.53) unstable; urgency=low
+
+ * Optimized gutil_parse_int()
+ * Added gutil_parse_uint()
+
+ -- Slava Monich <slava.monich@jolla.com> Wed, 05 May 2021 15:30:57 +0300
+
+libglibutil (1.0.52) unstable; urgency=low
+
+ * Added gutil_memdup()
+
+ -- Slava Monich <slava.monich@jolla.com> Sun, 18 Apr 2021 17:40:41 +0300
+
libglibutil (1.0.51) unstable; urgency=low
* Initialize default log settings from the environment
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/libglibutil/include/gutil_log.h
^
|
@@ -14,8 +14,8 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -139,6 +139,14 @@
const char* format,
va_list va);
+void
+gutil_log_dump(
+ const GLogModule* module,
+ int level,
+ const char* prefix,
+ const void* data,
+ gsize size); /* Since 1.0.55 */
+
/* Check if logging is enabled for the specified log level */
gboolean
gutil_log_enabled(
@@ -318,9 +326,12 @@
GLOG_LEVEL_DEBUG, f, ##args)
# define GDEBUG_(f,args...) gutil_log(GLOG_MODULE_CURRENT, \
GLOG_LEVEL_DEBUG, "%s() " f, __FUNCTION__, ##args)
+# define GDEBUG_DUMP(buf,n) gutil_log_dump(GLOG_MODULE_CURRENT, \
+ GLOG_LEVEL_DEBUG, NULL, buf, n) /* Since 1.0.55 */
# else
# define GDEBUG(f,args...) GLOG_NOTHING
# define GDEBUG_(f,args...) GLOG_NOTHING
+# define GDEBUG_DUMP(buf,n) GLOG_NOTHING /* Since 1.0.55 */
# endif /* GUTIL_LOG_DEBUG */
#else
# define GDEBUG_ GDEBUG
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/libglibutil/include/gutil_misc.h
^
|
@@ -70,6 +70,12 @@
int* value); /* Since 1.0.30 */
gboolean
+gutil_parse_uint(
+ const char* str,
+ int base,
+ unsigned int* value); /* Since 1.0.53 */
+
+gboolean
gutil_data_equal(
const GUtilData* data1,
const GUtilData* data2); /* Since 1.0.31 */
@@ -125,6 +131,26 @@
gutil_ptrv_free(
void** ptrv); /* Since 1.0.51 */
+void*
+gutil_memdup(
+ const void* ptr,
+ gsize size); /* Since 1.0.52 */
+
+gsize
+gutil_range_init_with_bytes(
+ GUtilRange* range,
+ GBytes* bytes); /* Since 1.0.55 */
+
+gboolean
+gutil_range_has_prefix(
+ const GUtilRange* range,
+ const GUtilData* prefix); /* Since 1.0.55 */
+
+gboolean
+gutil_range_skip_prefix(
+ GUtilRange* range,
+ const GUtilData* prefix); /* Since 1.0.55 */
+
G_END_DECLS
#endif /* GUTIL_MISC_H */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/libglibutil/include/gutil_types.h
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2014-2018 Jolla Ltd.
- * Copyright (C) 2014-2018 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2014-2021 Jolla Ltd.
+ * Copyright (C) 2014-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -14,8 +14,8 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -54,6 +54,11 @@
gsize size;
} GUtilData;
+typedef struct gutil_range {
+ const guint8* ptr;
+ const guint8* end;
+} GUtilRange; /* Since 1.0.54 */
+
#define GLOG_MODULE_DECL(m) extern GLogModule m;
typedef struct glog_module GLogModule;
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/libglibutil/rpm/libglibutil.spec
^
|
@@ -1,10 +1,12 @@
Name: libglibutil
-Version: 1.0.51
+
+Version: 1.0.55
Release: 0
Summary: Library of glib utilities
License: BSD
URL: https://git.sailfishos.org/mer-core/libglibutil
Source: %{name}-%{version}.tar.bz2
+
BuildRequires: pkgconfig(glib-2.0)
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/libglibutil/src/gutil_ints.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2017-2020 Jolla Ltd.
- * Copyright (C) 2017-2020 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2017-2021 Jolla Ltd.
+ * Copyright (C) 2017-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -32,6 +32,7 @@
#include "gutil_intarray.h"
#include "gutil_ints.h"
+#include "gutil_misc.h"
#include "gutil_macros.h"
struct gutil_ints {
@@ -45,10 +46,10 @@
GUtilInts*
gutil_ints_new(
const int* data,
- guint count)
+ guint n)
{
- if (data && count) {
- return gutil_ints_new_take(g_memdup(data, count*sizeof(int)), count);
+ if (data && n) {
+ return gutil_ints_new_take(gutil_memdup(data, n * sizeof(int)), n);
} else {
return NULL;
}
@@ -155,12 +156,12 @@
/* We can allow the caller to free the data */
result = (int*)ints->data;
} else {
- result = g_memdup(ints->data, ints->count * sizeof(int));
+ result = gutil_memdup(ints->data, ints->count * sizeof(int));
ints->free_func(ints->user_data);
}
gutil_slice_free(ints);
} else {
- result = g_memdup(ints->data, ints->count * sizeof(int));
+ result = gutil_memdup(ints->data, ints->count * sizeof(int));
}
return result;
} else {
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/libglibutil/src/gutil_log.c
^
|
@@ -490,6 +490,30 @@
return FALSE;
}
+void
+gutil_log_dump(
+ const GLogModule* module,
+ int level,
+ const char* prefix,
+ const void* data,
+ gsize size) /* Since 1.0.55 */
+{
+ if (gutil_log_enabled(module, level)) {
+ const guint8* ptr = data;
+ guint off = 0;
+
+ if (!prefix) prefix = "";
+ while (size > 0) {
+ char buf[GUTIL_HEXDUMP_BUFSIZE];
+ const guint consumed = gutil_hexdump(buf, ptr + off, size);
+
+ gutil_log(module, level, "%s%04X: %s", prefix, off, buf);
+ size -= consumed;
+ off += consumed;
+ }
+ }
+}
+
/* gutil_log_parse_option helper */
static
int
@@ -657,12 +681,12 @@
GDEBUG("Default log level %d", val);
}
- if (gutil_parse_int(getenv("GUTIL_LOG_TIMESTAMP"), 0, &val) && val > 0) {
+ if (gutil_parse_int(getenv("GUTIL_LOG_TIMESTAMP"), 0, &val) && val >= 0) {
gutil_log_timestamp = (val > 0);
GDEBUG("Timestamps %s", (val > 0) ? "enabled" : "disabled");
}
- if (gutil_parse_int(getenv("GUTIL_LOG_TID"), 0, &val) && val > 0) {
+ if (gutil_parse_int(getenv("GUTIL_LOG_TID"), 0, &val) && val >= 0) {
gutil_log_tid = (val > 0);
GDEBUG("Thread id prefix %s", (val > 0) ? "enabled" : "disabled");
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/libglibutil/src/gutil_misc.c
^
|
@@ -36,7 +36,6 @@
#include <ctype.h>
#include <limits.h>
-#include <errno.h>
void
gutil_disconnect_handlers(
@@ -46,6 +45,7 @@
{
if (G_LIKELY(instance) && G_LIKELY(ids)) {
int i;
+
for (i=0; i<count; i++) {
if (ids[i]) {
g_signal_handler_disconnect(instance, ids[i]);
@@ -64,6 +64,7 @@
if (str && data && len > 0 && !(len & 1)) {
gssize i;
guint8* ptr = data;
+
for (i=0; i<len; i+=2) {
static const guint8 hex[] = {
0, 1, 2, 3, 4, 5, 6, 7, /* 0x30..0x37 */
@@ -76,7 +77,8 @@
};
const char x1 = str[i];
const char x2 = str[i+1];
- if (isxdigit(x1) && isxdigit(x2)) {
+
+ if (g_ascii_isxdigit(x1) && g_ascii_isxdigit(x2)) {
*ptr++ = (hex[x1-0x30] << 4) + hex[x2-0x30];
} else {
return NULL;
@@ -95,9 +97,11 @@
if (str) {
if (len < 0) len = strlen(str);
if (len > 0 && !(len & 1)) {
- void* data = g_malloc(len/2);
+ const gsize n = len/2;
+ void* data = g_malloc(n);
+
if (gutil_hex2bin(str, len, data)) {
- return g_bytes_new_take(data, len/2);
+ return g_bytes_new_take(data, n);
}
g_free(data);
}
@@ -153,36 +157,74 @@
return bytes_dumped;
}
-/* Since 1.0.30 */
+static
+const char*
+gutil_strstrip(
+ const char* str,
+ char** tmp)
+{
+ /* Caller makes sure that str isn't NULL */
+ const gsize len = strlen(str);
+
+ if (g_ascii_isspace(str[0]) || g_ascii_isspace(str[len - 1])) {
+ /* Need to modify the original string */
+ return (*tmp = g_strstrip(gutil_memdup(str, len + 1)));
+ } else {
+ /* The original string is fine as is */
+ return str;
+ }
+}
+
gboolean
gutil_parse_int(
const char* str,
int base,
- int* value)
+ int* value) /* Since 1.0.30 */
+{
+ gboolean ok = FALSE;
+
+ if (str && str[0]) {
+ char* tmp = NULL;
+ char* end = NULL;
+ const char* stripped = gutil_strstrip(str, &tmp);
+ const gint64 ll = g_ascii_strtoll(stripped, &end, base);
+
+ ok = !*end && ll >= INT_MIN && ll <= INT_MAX;
+ if (ok && value) {
+ *value = (int)ll;
+ }
+ g_free(tmp);
+ }
+ return ok;
+}
+
+gboolean
+gutil_parse_uint(
+ const char* str,
+ int base,
+ unsigned int* value) /* Since 1.0.53 */
{
gboolean ok = FALSE;
if (str && str[0]) {
- char* str2 = g_strstrip(g_strdup(str));
- char* end = str2;
- gint64 l;
-
- errno = 0;
- l = g_ascii_strtoll(str2, &end, base);
- ok = !*end && errno != ERANGE && l >= INT_MIN && l <= INT_MAX;
+ char* tmp = NULL;
+ char* end = NULL;
+ const char* stripped = gutil_strstrip(str, &tmp);
+ const guint64 ull = g_ascii_strtoull(stripped, &end, base);
+
+ ok = !*end && ull <= UINT_MAX;
if (ok && value) {
- *value = (int)l;
+ *value = (unsigned int)ull;
}
- g_free(str2);
+ g_free(tmp);
}
return ok;
}
-/* since 1.0.31 */
gboolean
gutil_data_equal(
const GUtilData* data1,
- const GUtilData* data2)
+ const GUtilData* data2) /* Since 1.0.31 */
{
if (data1 == data2) {
return TRUE;
@@ -444,6 +486,68 @@
}
}
+/* Similar to g_memdup but takes gsize as the number of bytes to copy */
+void*
+gutil_memdup(
+ const void* ptr,
+ gsize size) /* Since 1.0.52 */
+{
+ if (G_LIKELY(ptr) && G_LIKELY(size)) {
+ void* copy = g_malloc(size);
+
+ memcpy(copy, ptr, size);
+ return copy;
+ } else {
+ return NULL;
+ }
+}
+
+gsize
+gutil_range_init_with_bytes(
+ GUtilRange* range,
+ GBytes* bytes) /* Since 1.0.55 */
+{
+ gsize size = 0;
+
+ if (G_LIKELY(range)) {
+ if (G_LIKELY(bytes)) {
+ range->ptr = (const guint8*) g_bytes_get_data(bytes, &size);
+ range->end = range->ptr + size;
+ } else {
+ memset(range, 0, sizeof(*range));
+ }
+ }
+ return size;
+}
+
+gboolean
+gutil_range_has_prefix(
+ const GUtilRange* range,
+ const GUtilData* prefix) /* Since 1.0.55 */
+{
+ if (G_LIKELY(range) && G_LIKELY(range->ptr) && G_LIKELY(prefix)) {
+ if (range->end > range->ptr) {
+ return (gsize)(range->end - range->ptr) >= prefix->size &&
+ !memcmp(range->ptr, prefix->bytes, prefix->size);
+ } else {
+ return !prefix->size;
+ }
+ }
+ return FALSE;
+}
+
+gboolean
+gutil_range_skip_prefix(
+ GUtilRange* range,
+ const GUtilData* prefix) /* Since 1.0.55 */
+{
+ if (gutil_range_has_prefix(range, prefix)) {
+ range->ptr += prefix->size;
+ return TRUE;
+ }
+ return FALSE;
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/libglibutil/test/test_log/test_log.c
^
|
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2017-2019 Jolla Ltd.
- * Copyright (C) 2017-2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2017-2021 Jolla Ltd.
+ * Copyright (C) 2017-2021 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -14,8 +14,8 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the names of the copyright holders nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -41,24 +41,24 @@
#include "gutil_log.h"
static TestOpt test_opt;
-
-/*==========================================================================*
- * Basic
- *==========================================================================*/
-
-static GString* test_log_basic_buf;
+static GString* test_log_buf;
static
void
-test_log_basic_fn(
+test_log_fn(
const char* name,
int level,
const char* format,
va_list va)
{
- g_string_append_vprintf(test_log_basic_buf, format, va);
+ g_string_append_vprintf(test_log_buf, format, va);
+ g_string_append_c(test_log_buf, '\n');
}
+/*==========================================================================*
+ * Basic
+ *==========================================================================*/
+
static
void
test_log_basic(
@@ -68,8 +68,8 @@
const GLogProc2 fn2 = gutil_log_func2;
const int level = gutil_log_default.level;
GLOG_MODULE_DEFINE2_(module, "test", gutil_log_default);
- test_log_basic_buf = g_string_new(NULL);
- gutil_log_func = test_log_basic_fn;
+ test_log_buf = g_string_new(NULL);
+ gutil_log_func = test_log_fn;
module.level = GLOG_LEVEL_INHERIT;
gutil_log_default.level = GLOG_LEVEL_ERR;
@@ -77,10 +77,10 @@
gutil_log(NULL, GLOG_LEVEL_DEBUG, "Debug!");
gutil_log(&module, GLOG_LEVEL_DEBUG, "Debug!");
gutil_log_assert(NULL, GLOG_LEVEL_WARN, "Test!", __FILE__, __LINE__);
- g_assert(!test_log_basic_buf->len);
+ g_assert(!test_log_buf->len);
gutil_log(&module, GLOG_LEVEL_ERR, "Err!");
- g_assert(test_log_basic_buf->len);
- g_string_set_size(test_log_basic_buf, 0);
+ g_assert(test_log_buf->len);
+ g_string_set_size(test_log_buf, 0);
/* With NULL parent, still gutil_log_default is going to be checked */
module.parent = NULL;
@@ -88,19 +88,19 @@
gutil_log(NULL, GLOG_LEVEL_DEBUG, "Debug!");
gutil_log(&module, GLOG_LEVEL_DEBUG, "Debug!");
gutil_log_assert(NULL, GLOG_LEVEL_WARN, "Test!", __FILE__, __LINE__);
- g_assert(!test_log_basic_buf->len);
+ g_assert(!test_log_buf->len);
gutil_log(&module, GLOG_LEVEL_ERR, "Err!");
- g_assert(test_log_basic_buf->len);
- g_string_set_size(test_log_basic_buf, 0);
+ g_assert(test_log_buf->len);
+ g_string_set_size(test_log_buf, 0);
gutil_log(&module, GLOG_LEVEL_ALWAYS, "Always!");
- g_assert(test_log_basic_buf->len);
- g_string_set_size(test_log_basic_buf, 0);
+ g_assert(test_log_buf->len);
+ g_string_set_size(test_log_buf, 0);
/* Test GLOG_FLAG_DISABLE */
module.flags |= GLOG_FLAG_DISABLE;
gutil_log(&module, GLOG_LEVEL_ALWAYS, "Always!");
- g_assert(!test_log_basic_buf->len);
+ g_assert(!test_log_buf->len);
module.flags &= ~GLOG_FLAG_DISABLE;
/* Without log functions these calls have no effect */
@@ -109,8 +109,8 @@
gutil_log_func2 = NULL;
gutil_log(NULL, GLOG_LEVEL_ALWAYS, "Always!");
- g_string_free(test_log_basic_buf, TRUE);
- test_log_basic_buf = NULL;
+ g_string_free(test_log_buf, TRUE);
+ test_log_buf = NULL;
gutil_log_default.level = level;
gutil_log_func = fn;
gutil_log_func2 = fn2;
@@ -169,7 +169,7 @@
stdout = default_stdout;
g_assert(fflush(out) == 0);
GDEBUG("%s", buf->str);
- g_assert(!g_strcmp0(buf->str, "WARNING: Test\n"));
+ g_assert_cmpstr(buf->str, == ,"WARNING: Test\n");
g_string_set_size(buf, 0);
/* Error prefix */
@@ -178,7 +178,7 @@
stdout = default_stdout;
g_assert(fflush(out) == 0);
GDEBUG("%s", buf->str);
- g_assert(!g_strcmp0(buf->str, "ERROR: Test\n"));
+ g_assert_cmpstr(buf->str, == ,"ERROR: Test\n");
g_string_set_size(buf, 0);
/* Empty name (dropped) */
@@ -188,7 +188,7 @@
stdout = default_stdout;
g_assert(fflush(out) == 0);
GDEBUG("%s", buf->str);
- g_assert(!g_strcmp0(buf->str, "Test\n"));
+ g_assert_cmpstr(buf->str, == ,"Test\n");
g_string_set_size(buf, 0);
/* Non-empty name */
@@ -198,7 +198,7 @@
stdout = default_stdout;
g_assert(fflush(out) == 0);
GDEBUG("%s", buf->str);
- g_assert(!g_strcmp0(buf->str, "[test] Test\n"));
+ g_assert_cmpstr(buf->str, == ,"[test] Test\n");
g_string_set_size(buf, 0);
/* Hide the name */
@@ -208,7 +208,7 @@
stdout = default_stdout;
g_assert(fflush(out) == 0);
GDEBUG("%s", buf->str);
- g_assert(!g_strcmp0(buf->str, "Test\n"));
+ g_assert_cmpstr(buf->str, == ,"Test\n");
g_string_set_size(buf, 0);
/* Forward output to test_log_drop */
@@ -284,13 +284,56 @@
const GLogProc fn = gutil_log_func;
g_assert(gutil_log_set_type(GLOG_TYPE_STDOUT, "test"));
g_assert(gutil_log_func == gutil_log_stdout);
- g_assert(!g_strcmp0(gutil_log_get_type(), GLOG_TYPE_STDOUT));
+ g_assert_cmpstr(gutil_log_get_type(), == ,GLOG_TYPE_STDOUT);
g_assert(gutil_log_set_type(GLOG_TYPE_STDERR, "test"));
g_assert(gutil_log_func == gutil_log_stderr);
- g_assert(!g_strcmp0(gutil_log_get_type(), GLOG_TYPE_STDERR));
+ g_assert_cmpstr(gutil_log_get_type(), == ,GLOG_TYPE_STDERR);
g_assert(!gutil_log_set_type("whatever", "test"));
gutil_log_func = NULL;
- g_assert(!g_strcmp0(gutil_log_get_type(), GLOG_TYPE_CUSTOM));
+ g_assert_cmpstr(gutil_log_get_type(), == ,GLOG_TYPE_CUSTOM);
+ gutil_log_func = fn;
+}
+
+/*==========================================================================*
+ * Dump
+ *==========================================================================*/
+
+static
+void
+test_log_dump(
+ void)
+{
+ static const guint8 short_data[] = { 0x01, 0x02, 0x03, 0x04 };
+ static const guint8 long_data[] = {
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+ 0x00
+ };
+
+ const GLogProc fn = gutil_log_func;
+ test_log_buf = g_string_new(NULL);
+ gutil_log_func = test_log_fn;
+
+ gutil_log_dump(&gutil_log_default, GLOG_LEVEL_NONE, NULL,
+ short_data, sizeof(short_data));
+ g_assert_cmpuint(test_log_buf->len, == ,0);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/libglibutil/test/test_misc/test_misc.c
^
|
@@ -175,18 +175,59 @@
g_assert(!gutil_parse_int("0 trailing garbage", 0, NULL));
g_assert(gutil_parse_int("0", 0, NULL));
g_assert(gutil_parse_int("0", 0, &value));
- g_assert(value == 0);
+ g_assert_cmpint(value, == ,0);
+ g_assert(gutil_parse_int("-1", 0, &value));
+ g_assert_cmpint(value, == ,-1);
+ g_assert(gutil_parse_int("42", 0, &value));
+ g_assert_cmpint(value, == ,42);
g_assert(!gutil_parse_int("0x10000000000000000", 0, &value));
g_assert(!gutil_parse_int("-2147483649", 0, &value));
g_assert(!gutil_parse_int("4294967295", 0, &value));
g_assert(gutil_parse_int(" 0x7fffffff ", 0, &value));
- g_assert(value == 0x7fffffff);
+ g_assert_cmpint(value, == ,0x7fffffff);
g_assert(gutil_parse_int(" 7fffffff ", 16, &value));
- g_assert(value == 0x7fffffff);
+ g_assert_cmpint(value, == ,0x7fffffff);
+ g_assert(gutil_parse_int("7ffffffe ", 16, &value));
+ g_assert_cmpint(value, == ,0x7ffffffe);
g_assert(!gutil_parse_int("0xffffffff", 0, &value));
}
/*==========================================================================*
+ * parse_uint
+ *==========================================================================*/
+
+static
+void
+test_parse_uint(
+ void)
+{
+ unsigned int value;
+
+ g_assert(!gutil_parse_uint(NULL, 0, NULL));
+ g_assert(!gutil_parse_uint("", 0, NULL));
+ g_assert(!gutil_parse_uint("garbage", 0, NULL));
+ g_assert(!gutil_parse_uint("0 trailing garbage", 0, NULL));
+ g_assert(gutil_parse_uint("0", 0, NULL));
+ g_assert(gutil_parse_uint("0", 0, &value));
+ g_assert_cmpuint(value, == ,0);
+ g_assert(gutil_parse_uint("42", 0, &value));
+ g_assert_cmpuint(value, == ,42);
+ g_assert(!gutil_parse_uint("0x10000000000000000", 0, &value));
+ g_assert(!gutil_parse_uint("-2147483649", 0, &value));
+ g_assert(!gutil_parse_uint("-1", 0, &value));
+ g_assert(gutil_parse_uint("4294967295", 0, &value));
+ g_assert_cmpuint(value, == ,4294967295);
+ g_assert(gutil_parse_uint(" 0x7fffffff ", 0, &value));
+ g_assert_cmpuint(value, == ,0x7fffffff);
+ g_assert(gutil_parse_uint(" 7fffffff ", 16, &value));
+ g_assert_cmpuint(value, == ,0x7fffffff);
+ g_assert(gutil_parse_uint("7ffffffe ", 16, &value));
+ g_assert_cmpuint(value, == ,0x7ffffffe);
+ g_assert(gutil_parse_uint("0xffffffff", 0, &value));
+ g_assert_cmpuint(value, == ,0xffffffff);
+}
+
+/*==========================================================================*
* data_equal
*==========================================================================*/
@@ -520,6 +561,103 @@
}
/*==========================================================================*
+ * memdup
+ *==========================================================================*/
+
+static
+void
+test_memdup(
+ void)
+{
+ static const guint8 data[] = { 0x01, 0x02, 0x03 };
+ void* copy = gutil_memdup(data, sizeof(data));
+
+ g_assert(copy);
+ g_assert(!memcmp(copy, data, sizeof(data)));
+ g_free(copy);
+
+ g_assert(!gutil_memdup(data, 0));
+ g_assert(!gutil_memdup(NULL, 0));
+ g_assert(!gutil_memdup(NULL, 1));
+}
+
+/*==========================================================================*
+ * range_init
+ *==========================================================================*/
+
+static
+void
+test_range_init(
+ void)
+{
+ static const guint8 data[] = { 0x01, 0x02, 0x03 };
+ GBytes* bytes = g_bytes_new_static(data, sizeof(data));
+ GUtilRange range;
+
+ g_assert(!gutil_range_init_with_bytes(NULL, NULL));
+ g_assert(!gutil_range_init_with_bytes(&range, NULL));
+ g_assert(!range.ptr);
+ g_assert(!range.end);
+
+ g_assert(gutil_range_init_with_bytes(&range, bytes) == sizeof(data));
+ g_assert(range.ptr == data);
+ g_assert(range.end == (data + sizeof(data)));
+ g_bytes_unref(bytes);
+}
+
+/*==========================================================================*
+ * range_prefix
+ *==========================================================================*/
+
+static
+void
+test_range_prefix(
+ void)
+{
+ static const guint8 data[] = { 0x01, 0x02, 0x03, 0x04 };
+ static const guint8 prefix[] = { 0x01, 0x02 };
+ static const guint8 not_prefix[] = { 0x03, 0x04 };
+ static const guint8 too_long[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
+ GUtilData prefix_data, not_prefix_data, too_long_data;
+ GUtilRange range;
+
+ memset(&range, 0, sizeof(range));
+ g_assert(!gutil_range_has_prefix(NULL, NULL));
+ g_assert(!gutil_range_has_prefix(&range, NULL));
+
+ not_prefix_data.bytes = not_prefix;
+ not_prefix_data.size = sizeof(not_prefix);
+ too_long_data.bytes = too_long;
+ too_long_data.size = sizeof(too_long);
+
+ range.end = range.ptr = data; /* Empty range */
+ memset(&prefix_data, 0, sizeof(prefix_data)); /* Empty prefix */
+ /* Empty range doesn't have NULL prefix */
+ g_assert(!gutil_range_has_prefix(&range, NULL));
+ /* But does have empty prefix */
+ g_assert(gutil_range_has_prefix(&range, &prefix_data));
+
+ /* And doesn't have non-empty prefix */
+ g_assert(!gutil_range_has_prefix(&range, ¬_prefix_data));
+ prefix_data.bytes = prefix;
+ prefix_data.size = sizeof(prefix);
+ g_assert(!gutil_range_has_prefix(&range, &prefix_data));
+
+ range.end = range.ptr + sizeof(data);
+
+ g_assert(gutil_range_has_prefix(&range, &prefix_data));
+ g_assert(!gutil_range_has_prefix(&range, ¬_prefix_data));
+ g_assert(!gutil_range_has_prefix(&range, &too_long_data));
+
+ /* Test skipping */
+ g_assert(!gutil_range_skip_prefix(&range, ¬_prefix_data));
+ g_assert(range.ptr == data);
+
+ g_assert(gutil_range_skip_prefix(&range, &prefix_data));
+ g_assert(range.ptr == (data + prefix_data.size));
+}
+
+/*==========================================================================*
* Common
*==========================================================================*/
@@ -540,6 +678,7 @@
g_test_add_func(TEST_("hex2bin"), test_hex2bin);
g_test_add_func(TEST_("hexdump"), test_hexdump);
g_test_add_func(TEST_("parse_int"), test_parse_int);
+ g_test_add_func(TEST_("parse_uint"), test_parse_uint);
g_test_add_func(TEST_("data_equal"), test_data_equal);
g_test_add_func(TEST_("data_prefix"), test_data_prefix);
g_test_add_func(TEST_("data_suffix"), test_data_suffix);
@@ -550,6 +689,9 @@
g_test_add_func(TEST_("bytes_equal"), test_bytes_equal);
g_test_add_func(TEST_("ptrv_lenght"), test_ptrv_length);
g_test_add_func(TEST_("ptrv_free"), test_ptrv_free);
+ g_test_add_func(TEST_("memdup"), test_memdup);
+ g_test_add_func(TEST_("range_init"), test_range_init);
+ g_test_add_func(TEST_("range_prefix"), test_range_prefix);
test_init(&test_opt, argc, argv);
return g_test_run();
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilnotes-1.0.26.tar.gz/translations/harbour-foilnotes-pl.ts
^
|
@@ -284,7 +284,7 @@
<message id="foilnotes-remorse-decrypting">
<source>Decrypting</source>
<extracomment>Decrypting note in 5 seconds</extracomment>
- <translation>Decrypting</translation>
+ <translation>Odszyfrowywanie</translation>
</message>
<message id="foilnotes-remorse-decrypting_selected" numerus="yes">
<source>Decrypting %0 selected notes</source>
@@ -353,32 +353,32 @@
<message id="color_picker-action-select_color">
<source>Select color</source>
<extracomment>Dialog title label</extracomment>
- <translation type="unfinished">Wybierz kolor</translation>
+ <translation>Wybierz kolor</translation>
</message>
<message id="color_picker-action-add_color">
<source>Add color</source>
<extracomment>Dialog title label</extracomment>
- <translation type="unfinished">Dodaj kolor</translation>
+ <translation>Dodaj kolor</translation>
</message>
<message id="color_picker-menu-reset_colors">
<source>Reset colors</source>
<extracomment>Pulley menu item</extracomment>
- <translation type="unfinished">Zresetuj kolory</translation>
+ <translation>Zresetuj kolory</translation>
</message>
<message id="color_picker-slider-hue">
<source>Color</source>
<extracomment>Hue slider label</extracomment>
- <translation type="unfinished">Kolor</translation>
+ <translation>Kolor</translation>
</message>
<message id="color_picker-slider-brightness">
<source>Brightness</source>
<extracomment>Brightness slider label</extracomment>
- <translation type="unfinished">Jasność</translation>
+ <translation>Jasność</translation>
</message>
<message id="color_picker-text-hex_notation">
<source>Hex notation</source>
<extracomment>Text field description</extracomment>
- <translation type="unfinished">Format szesnastkowy</translation>
+ <translation>Format szesnastkowy</translation>
</message>
</context>
</TS>
|