[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,6 +2,6 @@
<service name="tar_git">
<param name="url">https://github.com/monich/harbour-foilauth.git</param>
<param name="branch">master</param>
- <param name="revision">77fd8ce</param>
+ <param name="revision">280e9dd</param>
</service>
</services>
\ No newline at end of file
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/.gitignore
^
|
@@ -1,2 +1,2 @@
build
-harbour-foilauth.pro.user
+harbour-foilauth.pro.user*
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/LICENSE
^
|
@@ -1,5 +1,5 @@
Copyright (C) 2019-2022 Jolla Ltd.
-Copyright (C) 2019-2022 Slava Monich <slava@monich.com>
+Copyright (C) 2019-2023 Slava Monich <slava@monich.com>
You may use this file under the terms of the BSD license as follows:
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/app.pro
^
|
@@ -80,6 +80,7 @@
src/FoilAuth.h \
src/FoilAuthDefs.h \
src/FoilAuthFavoritesModel.h \
+ src/FoilAuthGroupModel.h \
src/FoilAuthImportModel.h \
src/FoilAuthModel.h \
src/FoilAuthSettings.h \
@@ -92,6 +93,7 @@
SOURCES += \
src/FoilAuth.cpp \
src/FoilAuthFavoritesModel.cpp \
+ src/FoilAuthGroupModel.cpp \
src/FoilAuthImportModel.cpp \
src/FoilAuthModel.cpp \
src/FoilAuthSettings.cpp \
@@ -169,11 +171,13 @@
$${HARBOUR_LIB_SRC}/HarbourTask.cpp
HARBOUR_QML_COMPONENTS = \
+ $${HARBOUR_LIB_QML}/HarbourBadge.qml \
$${HARBOUR_LIB_QML}/HarbourFitLabel.qml \
$${HARBOUR_LIB_QML}/HarbourHighlightIcon.qml \
$${HARBOUR_LIB_QML}/HarbourIconTextButton.qml \
$${HARBOUR_LIB_QML}/HarbourHintIconButton.qml \
$${HARBOUR_LIB_QML}/HarbourPasswordInputField.qml \
+ $${HARBOUR_LIB_QML}/HarbourPressEffect.qml \
$${HARBOUR_LIB_QML}/HarbourShakeAnimation.qml \
$${HARBOUR_LIB_QML}/HarbourTextFlip.qml
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil-ui/FoilUiGenerateKeyView.qml
^
|
@@ -4,23 +4,23 @@
import "../harbour"
Item {
- id: view
+ id: thisView
property var foilUi
property var foilModel
property Page page
property alias prompt: promptLabel.text
- readonly property int minPassphraseLen: 8
- readonly property bool canGenerate: inputField.text.length >= minPassphraseLen && !generating
- readonly property bool generating: foilUi.isGeneratingKeyState(foilModel.foilState)
- readonly property bool landscapeLayout: page.isLandscape && Screen.sizeCategory < Screen.Large
- readonly property int fullHeight: page.isPortrait ? Screen.height : Screen.width
+ readonly property int _minPassphraseLen: 8
+ readonly property bool _canGenerate: inputField.text.length >= _minPassphraseLen && !_generating
+ readonly property bool _generating: foilUi.isGeneratingKeyState(foilModel.foilState)
+ readonly property bool _landscapeLayout: page.isLandscape && Screen.sizeCategory < Screen.Large
+ readonly property int _fullHeight: page.isPortrait ? Screen.height : Screen.width
function generateKey() {
- if (canGenerate) {
+ if (_canGenerate) {
var dialog = pageStack.push(Qt.resolvedUrl("FoilUiConfirmPasswordDialog.qml"), {
- foilUi: view.foilUi,
+ foilUi: thisView.foilUi,
allowedOrientations: page.allowedOrientations,
password: inputField.text
})
@@ -50,8 +50,8 @@
id: panel
width: parent.width
- height: childrenRect.height + (landscapeLayout ? 0 : Theme.paddingLarge)
- y: Math.min((fullHeight - height)/2, parent.height - panel.height)
+ height: childrenRect.height + (_landscapeLayout ? 0 : Theme.paddingLarge)
+ y: Math.min((_fullHeight - height)/2, parent.height - panel.height)
InfoLabel {
id: promptLabel
@@ -66,16 +66,16 @@
id: keySize
label: foilUi.qsTrGenerateKeySizeLabel()
- enabled: !generating
- width: parent.width
+ enabled: !_generating
+ width: inputField.width
anchors {
top: promptLabel.bottom
topMargin: Theme.paddingLarge
}
menu: ContextMenu {
MenuItem { text: "1024" }
- MenuItem { text: "1500" }
MenuItem { text: "2048" }
+ MenuItem { text: "4096" }
}
Component.onCompleted: currentIndex = 2 // default
}
@@ -88,11 +88,11 @@
top: keySize.bottom
topMargin: Theme.paddingLarge
}
- label: text.length < minPassphraseLen ?
- foilUi.qsTrGenerateKeyPasswordDescription(minPassphraseLen) :
+ label: text.length < _minPassphraseLen ?
+ foilUi.qsTrGenerateKeyPasswordDescription(_minPassphraseLen) :
placeholderText
- enabled: !generating
- EnterKey.enabled: canGenerate
+ enabled: !_generating
+ EnterKey.enabled: _canGenerate
EnterKey.onClicked: generateKey()
}
@@ -100,10 +100,10 @@
id: button
anchors.bottomMargin: Theme.paddingLarge
- text: generating ?
+ text: _generating ?
foilUi.qsTrGenerateKeyButtonGenerating() :
foilUi.qsTrGenerateKeyButtonGenerate()
- enabled: canGenerate
+ enabled: _canGenerate
onClicked: generateKey()
}
}
@@ -111,7 +111,7 @@
states: [
State {
name: "portrait"
- when: !landscapeLayout
+ when: !_landscapeLayout
changes: [
AnchorChanges {
target: inputField
@@ -138,7 +138,7 @@
},
State {
name: "landscape"
- when: landscapeLayout
+ when: _landscapeLayout
changes: [
AnchorChanges {
target: inputField
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/debian/changelog
^
|
@@ -1,3 +1,29 @@
+libfoil (1.0.27) unstable; urgency=low
+
+ * Reduced log level for non-critical warnings
+ * Guard foil_log declaration with extern "C"
+ * Added foil_output_cipher variants with HMAC
+ * Added foil_output_write_byte()
+ * Added foil_hmac_reset()
+ * Added foil_digest_reset()
+ * Added foil_digest_data_buf()
+
+ -- Slava Monich <slava@monich.com> Wed, 23 Nov 2022 04:01:29 +0200
+
+libfoil (1.0.26) unstable; urgency=low
+
+ * Added foil_output_cipher_new()
+ * Added foil_key_to_binary_format()
+ * Fixed foil_output_write_bytes() error handling
+ * Fixed a few unit test dependency issues
+ * Don't update finished digest
+ * Compatibility with GNU Make 4
+ * Compatibility with OpenSSL 3
+ * Bumped debhelper compat level to 7
+ * Housekeeping
+
+ -- Slava Monich <slava@monich.com> Mon, 17 Oct 2022 21:44:29 +0300
+
libfoil (1.0.25) unstable; urgency=low
* Added foil_kdf_pbkdf2()
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/debian/compat
^
|
@@ -1 +1 @@
-5
+7
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/Makefile
^
|
@@ -62,7 +62,7 @@
#
VERSION_FILE = $(INCLUDE_DIR)/foil_version.h
-get_version = $(shell grep -E "^ *\\\#define +FOIL_VERSION_$1 +[0-9]+$$" $(VERSION_FILE) | sed "s/ */ /g" | cut -d " " -f 3)
+get_version = $(shell grep -E '^ *\#define +FOIL_VERSION_$1 +[0-9]+$$' $(VERSION_FILE) | sed 's/ */ /g' | cut -d ' ' -f 3)
VERSION_MAJOR = $(call get_version,MAJOR)
VERSION_MINOR = $(call get_version,MINOR)
@@ -115,6 +115,8 @@
foil_key_rsa_public.c \
foil_output.c \
foil_output_base64.c \
+ foil_output_cipher.c \
+ foil_output_cipher_mem.c \
foil_output_digest.c \
foil_output_file.c \
foil_output_mem.c \
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/include/foil_digest.h
^
|
@@ -1,29 +1,31 @@
/*
- * Copyright (C) 2016-2021 by Slava Monich
+ * Copyright (C) 2016-2022 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
@@ -54,6 +56,13 @@
const void* data,
gsize size);
+gboolean
+foil_digest_data_buf(
+ GType type,
+ const void* data,
+ gsize size,
+ void* digest); /* Since 1.0.27 */
+
GBytes*
foil_digest_bytes(
GType type,
@@ -83,23 +92,27 @@
FoilDigest*
foil_digest_clone(
- FoilDigest* digest); /* Since 1.0.8 */
+ FoilDigest* digest); /* Since 1.0.8 */
gboolean
foil_digest_copy(
FoilDigest* digest,
- FoilDigest* source); /* Since 1.0.8 */
+ FoilDigest* source); /* Since 1.0.8 */
-void
+gboolean
+foil_digest_reset(
+ FoilDigest* digest); /* Since 1.0.27 */
+
+gboolean
foil_digest_update(
FoilDigest* digest,
const void* data,
- gsize size);
+ gsize size); /* Has return value since 1.0.26 */
-void
+gboolean
foil_digest_update_bytes(
FoilDigest* self,
- GBytes* bytes);
+ GBytes* bytes); /* Has return value since 1.0.26 */
GBytes*
foil_digest_finish(
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/include/foil_hmac.h
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2018 by Slava Monich
+ * Copyright (C) 2018-2022 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
@@ -71,6 +76,10 @@
const void* data,
gsize size);
+void
+foil_hmac_reset(
+ FoilHmac* hmac); /* Since 1.0.27 */
+
GBytes*
foil_hmac_finish(
FoilHmac* hmac);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/include/foil_key.h
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2019 by Slava Monich
+ * Copyright (C) 2016-2022 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
@@ -64,6 +64,13 @@
FOIL_KEY_EXPORT_FORMAT_PKCS8 /* Since 1.0.7 */
} FoilKeyExportFormat;
+/* Format of binary key data */
+typedef enum foil_key_binary_format { /* Since 1.0.26 */
+ FOIL_KEY_BINARY_FORMAT_DEFAULT, /* Valid for all key formats */
+ FOIL_KEY_EXPORT_FORMAT_RSA_PKCS1, /* RFC 3447 (Appendix A) */
+ FOIL_KEY_BINARY_FORMAT_RSA_SSH /* RFC 4253 (ssh-rsa format) */
+} FoilKeyBinaryFormat;
+
FoilKey*
foil_key_new_from_data(
GType type,
@@ -171,6 +178,11 @@
foil_key_to_bytes(
FoilKey* key);
+GBytes*
+foil_key_to_binary_format(
+ FoilKey* key,
+ FoilKeyBinaryFormat format); /* Since 1.0.26 */
+
gboolean
foil_key_export(
FoilKey* key,
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/include/foil_log.h
^
|
@@ -1,16 +1,19 @@
/*
- * Copyright (C) 2016-2019 by Slava Monich
+ * Copyright (C) 2016-2022 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
+ * 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
+ * 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
@@ -44,8 +47,12 @@
log(foil_log_output) \
log(foil_log_random)
+G_BEGIN_DECLS
+
FOIL_LOG_MODULES(GLOG_MODULE_DECL)
+G_END_DECLS
+
#endif /* FOIL_LOG_H */
/*
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/include/foil_output.h
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2016-2018 by Slava Monich
+ * Copyright (C) 2016-2022 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
@@ -62,10 +67,14 @@
FoilOutput* out,
GBytes* bytes);
-/* Since 1.0.9 */
guint
foil_output_write_eol(
- FoilOutput* out);
+ FoilOutput* out); /* Since 1.0.9 */
+
+gboolean
+foil_output_write_byte(
+ FoilOutput* out,
+ guint8 byte); /* Since 1.0.27 */
#define foil_output_write_all(out,buf,size) \
(foil_output_write(out,buf,size) == (gssize)(size))
@@ -93,6 +102,30 @@
GByteArray* buf);
FoilOutput*
+foil_output_cipher_new(
+ FoilOutput* out,
+ FoilCipher* cipher,
+ FoilDigest* digest); /* Since 1.0.26 */
+
+FoilOutput*
+foil_output_cipher_new2(
+ FoilOutput* out,
+ FoilCipher* cipher,
+ FoilHmac* hmac); /* Since 1.0.27 */
+
+FoilOutput*
+foil_output_cipher_mem_new(
+ GByteArray* buf,
+ FoilCipher* cipher,
+ FoilDigest* digest); /* Since 1.0.26 */
+
+FoilOutput*
+foil_output_cipher_mem_new2(
+ GByteArray* buf,
+ FoilCipher* cipher,
+ FoilHmac* hmac); /* Since 1.0.27 */
+
+FoilOutput*
foil_output_digest_new(
FoilOutput* out,
FoilDigest* digest);
@@ -110,11 +143,10 @@
#define FOIL_OUTPUT_BASE64_CLOSE (0x01) /* Close the target stream */
#define FOIL_OUTPUT_BASE64_FILESAFE (0x02) /* Use filename safe enciding */
-/* Since 1.0.1 */
FoilOutput*
foil_output_file_new(
FILE* file,
- guint flags);
+ guint flags); /* Since 1.0.1 */
#define FOIL_OUTPUT_FILE_CLOSE (0x01) /* Close the file when done */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/include/foil_version.h
^
|
@@ -58,8 +58,8 @@
#define FOIL_VERSION_MAJOR 1
#define FOIL_VERSION_MINOR 0
-#define FOIL_VERSION_RELEASE 25
-#define FOIL_VERSION_STRING "1.0.25"
+#define FOIL_VERSION_RELEASE 27
+#define FOIL_VERSION_STRING "1.0.27"
/* Version as a single word */
#define FOIL_VERSION_WORD(v1,v2,v3) \
@@ -86,6 +86,8 @@
/* Specific versions */
#define FOIL_VERSION_1_0_24 FOIL_VERSION_WORD(1,0,24)
#define FOIL_VERSION_1_0_25 FOIL_VERSION_WORD(1,0,25)
+#define FOIL_VERSION_1_0_26 FOIL_VERSION_WORD(1,0,26)
+#define FOIL_VERSION_1_0_27 FOIL_VERSION_WORD(1,0,27)
#endif /* FOIL_VERSION_H */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/foil_digest.c
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2016-2018 by Slava Monich
+ * Copyright (C) 2016-2022 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,6 +56,7 @@
{
gsize size = 0;
FoilDigestClass* klass = foil_digest_class_ref(type);
+
if (G_LIKELY(klass)) {
size = klass->size;
g_type_class_unref(klass);
@@ -64,6 +70,7 @@
{
gsize size = 0;
FoilDigestClass* klass = foil_digest_class_ref(type);
+
if (G_LIKELY(klass)) {
size = klass->block_size;
g_type_class_unref(klass);
@@ -77,6 +84,7 @@
{
const char* name = NULL;
FoilDigestClass* klass = foil_digest_class_ref(type);
+
if (G_LIKELY(klass)) {
name = klass->name;
g_type_class_unref(klass);
@@ -91,10 +99,13 @@
gsize size)
{
GBytes* result = NULL;
+
if (G_LIKELY(data || !size)) {
FoilDigestClass* klass = foil_digest_class_ref(type);
+
if (G_LIKELY(klass)) {
void* digest = klass->fn_digest_alloc();
+
klass->fn_digest(data, size, digest);
result = g_bytes_new_with_free_func(digest, klass->size,
klass->fn_digest_free, digest);
@@ -104,18 +115,39 @@
return result;
}
+gboolean
+foil_digest_data_buf(
+ GType type,
+ const void* data,
+ gsize size,
+ void* digest) /* Since 1.0.27 */
+{
+ /* The output buffer is supposed to be large enough */
+ if (G_LIKELY(data || !size) && G_LIKELY(digest)) {
+ FoilDigestClass* klass = foil_digest_class_ref(type);
+
+ if (G_LIKELY(klass)) {
+ klass->fn_digest(data, size, digest);
+ g_type_class_unref(klass);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
GBytes*
foil_digest_bytes(
GType type,
GBytes* bytes)
{
- GBytes* result = NULL;
if (G_LIKELY(bytes)) {
gsize size = 0;
const void* data = g_bytes_get_data(bytes, &size);
- result = foil_digest_data(type, data, size);
+
+ return foil_digest_data(type, data, size);
+ } else {
+ return NULL;
}
- return result;
}
gsize
@@ -145,6 +177,7 @@
{
FoilDigest* digest = NULL;
FoilDigestClass* klass = foil_digest_class_ref(type);
+
if (G_LIKELY(klass)) {
digest = g_object_new(type, NULL);
g_type_class_unref(klass);
@@ -175,11 +208,12 @@
FoilDigest*
foil_digest_clone(
- FoilDigest* self)
+ FoilDigest* self) /* Since 1.0.8 */
{
if (G_LIKELY(self)) {
GType type = G_TYPE_FROM_INSTANCE(self);
FoilDigest* clone = foil_digest_new(type);
+
if (foil_digest_copy(clone, self)) {
return clone;
}
@@ -191,7 +225,7 @@
gboolean
foil_digest_copy(
FoilDigest* self,
- FoilDigest* source)
+ FoilDigest* source) /* Since 1.0.8 */
{
if (G_LIKELY(self) && G_LIKELY(source)) {
if (self == source) {
@@ -200,6 +234,7 @@
} else {
/* Both must be of the same class */
FoilDigestClass* klass = FOIL_DIGEST_GET_CLASS(self);
+
if (klass == FOIL_DIGEST_GET_CLASS(source) && klass->fn_copy) {
klass->fn_copy(self, source);
if (self->result) {
@@ -216,27 +251,52 @@
return FALSE;
}
-void
+gboolean
+foil_digest_reset(
+ FoilDigest* self) /* Since 1.0.27 */
+{
+ if (G_LIKELY(self)) {
+ FoilDigestClass* klass = FOIL_DIGEST_GET_CLASS(self);
+
+ if (klass->fn_reset) {
+ klass->fn_reset(self);
+ if (self->result) {
+ g_bytes_unref(self->result);
+ self->result = NULL;
+ }
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+gboolean
foil_digest_update(
FoilDigest* self,
const void* data,
- gsize size)
+ gsize size) /* Has return value since 1.0.26 */
{
- if (G_LIKELY(self)) {
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/foil_digest_p.h
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2022 by Slava Monich
+ * Copyright (C) 2016-2022 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
@@ -52,6 +52,7 @@
void* (*fn_digest_alloc)(void);
void (*fn_digest_free)(void* md);
void (*fn_digest)(const void* in, gsize n, void* md);
+ void (*fn_reset)(FoilDigest* digest);
void (*fn_copy)(FoilDigest* digest, FoilDigest* source);
void (*fn_update)(FoilDigest* digest, const void* data, gsize size);
void (*fn_finish)(FoilDigest* digest, void* md);
@@ -94,6 +95,44 @@
FoilDigest* digest)
FOIL_INTERNAL;
+/* Callbacks for generic FoilDigest/FoilHmac actions (all ignore NULL) */
+
+typedef
+void
+(*FoilDigestGenericUpdateFunc)(
+ void* digest,
+ const void* data,
+ gsize size);
+
+void
+foil_digest_update_digest(
+ void* digest, /* FoilDigest */
+ const void* data,
+ gsize size)
+ FOIL_INTERNAL;
+
+void
+foil_digest_update_hmac(
+ void* digest, /* FoilHmac */
+ const void* data,
+ gsize size)
+ FOIL_INTERNAL;
+
+typedef
+void
+(*FoilDigestGenericUnrefFunc)(
+ void* digest);
+
+void
+foil_digest_unref_digest(
+ void* digest) /* FoilDigest */
+ FOIL_INTERNAL;
+
+void
+foil_digest_unref_hmac(
+ void* digest) /* FoilHmac */
+ FOIL_INTERNAL;
+
#endif /* FOIL_DIGEST_P_H */
/*
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/foil_hmac.c
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2018 by Slava Monich
+ * Copyright (C) 2018-2022 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.
- *
- * 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.
+ * 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 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
@@ -42,30 +47,64 @@
* ipad is the byte 0x36 repeated 64 times
* opad is the byte 0x5c repeated 64 times
* and text is the data being protected
+ *
+ * Since 1.0.8
*/
struct foil_hmac {
gint ref_count;
FoilDigest* digest;
+ void* key;
+ gsize keylen;
guint8* k_opad;
GBytes* result;
};
static
void
+foil_hmac_init(
+ FoilHmac* self)
+{
+ const gsize keylen = self->keylen;
+ const gsize blocksize = foil_digest_block_size(self->digest);
+ guint8* k_ipad = g_slice_alloc(blocksize);
+ gsize i;
+
+ /* XOR key with ipad and opad values */
+ if (keylen) {
+ memcpy(k_ipad, self->key, keylen);
+ memcpy(self->k_opad, self->key, keylen);
+ }
+ if (blocksize > keylen) {
+ memset(k_ipad + keylen, 0, blocksize - keylen);
+ memset(self->k_opad + keylen, 0, blocksize - keylen);
+ }
+ for (i = 0; i < blocksize; i++) {
+ k_ipad[i] ^= 0x36;
+ self->k_opad[i] ^= 0x5c;
+ }
+
+ /* Perform inner digest */
+ foil_digest_update(self->digest, k_ipad, blocksize);
+ memset(k_ipad, 0, blocksize);
+ g_slice_free1(blocksize, k_ipad);
+}
+
+static
+void
foil_hmac_finalize(
FoilHmac* self)
{
+ const gsize blocksize = foil_digest_block_size(self->digest);
+
if (self->result) {
g_bytes_unref(self->result);
- GASSERT(!self->digest);
- GASSERT(!self->k_opad);
- } else {
- const gsize blocksize = foil_digest_block_size(self->digest);
- memset(self->k_opad, 0, blocksize);
- g_slice_free1(blocksize, self->k_opad);
- foil_digest_unref(self->digest);
}
+ memset(self->key, 0, self->keylen);
+ memset(self->k_opad, 0, blocksize);
+ g_slice_free1(self->keylen, self->key);
+ g_slice_free1(blocksize, self->k_opad);
+ foil_digest_unref(self->digest);
}
FoilHmac*
@@ -99,12 +138,10 @@
gsize keylen)
{
FoilDigest* digest = foil_digest_new(digest_type);
- if (digest) {
+
+ if (G_LIKELY(digest)) {
FoilHmac* hmac = g_slice_new0(FoilHmac);
const gsize blocksize = foil_digest_block_size(digest);
- guint8* k_ipad = g_slice_alloc0(blocksize);
- GBytes* tmp_key = NULL;
- gsize i;
g_atomic_int_set(&hmac->ref_count, 1);
hmac->digest = digest;
@@ -112,25 +149,16 @@
/* If key is longer than digest block size, reset it to H(key) */
if (keylen > blocksize) {
- tmp_key = foil_digest_data(digest_type, key, keylen);
- key = g_bytes_get_data(tmp_key, &keylen);
+ hmac->keylen = blocksize;
+ hmac->key = g_slice_alloc0(blocksize);
+ foil_digest_data_buf(digest_type, key, keylen, hmac->key);
+ } else if (keylen > 0) {
+ hmac->keylen = keylen;
+ hmac->key = g_slice_alloc(keylen);
+ memcpy(hmac->key, key, keylen);
}
- /* XOR key with ipad and opad values */
- memcpy(k_ipad, key, keylen);
- memcpy(hmac->k_opad, key, keylen);
- for (i = 0; i < blocksize; i++) {
- k_ipad[i] ^= 0x36;
- hmac->k_opad[i] ^= 0x5c;
- }
-
- /* Perform inner digest */
- foil_digest_update(digest, k_ipad, blocksize);
- memset(k_ipad, 0, blocksize);
- g_slice_free1(blocksize, k_ipad);
- if (tmp_key) {
- g_bytes_unref(tmp_key);
- }
+ foil_hmac_init(hmac);
return hmac;
}
return NULL;
@@ -142,16 +170,17 @@
{
if (G_LIKELY(self)) {
FoilHmac* hmac = g_slice_new0(FoilHmac);
+ const gsize blocksize = foil_digest_block_size(self->digest);
+
g_atomic_int_set(&hmac->ref_count, 1);
+ hmac->digest = foil_digest_clone(self->digest);
+ hmac->keylen = self->keylen;
+ hmac->key = g_slice_alloc(self->keylen);
+ hmac->k_opad = g_slice_alloc(blocksize);
+ memcpy(hmac->key, self->key, self->keylen);
+ memcpy(hmac->k_opad, self->k_opad, blocksize);
if (self->result) {
hmac->result = g_bytes_ref(self->result);
- GASSERT(!self->digest);
- GASSERT(!self->k_opad);
- } else {
- const gsize blocksize = foil_digest_block_size(self->digest);
- hmac->digest = foil_digest_clone(self->digest);
- hmac->k_opad = g_slice_alloc0(blocksize);
- memcpy(hmac->k_opad, self->k_opad, blocksize);
}
return hmac;
}
@@ -167,6 +196,7 @@
/* Clean up the old state but don't deallocate k_opad just yet */
FoilDigest* prev_digest = self->digest;
guint8* prev_k_opad = self->k_opad;
+
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/foil_kdf.c
^
|
@@ -86,7 +86,7 @@
* the digest type is valid.
*/
FoilHmac* pmac = foil_hmac_new(digest, pw, (pwlen >= 0) ?
- pwlen : strlen(pw));
+ (gsize) pwlen : strlen(pw));
/*
* 2. Let l be the number of hLen-octet blocks in the derived key,
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/foil_key.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2021 by Slava Monich <slava@monich.com>
+ * Copyright (C) 2016-2022 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
@@ -121,10 +121,18 @@
foil_key_to_bytes(
FoilKey* self)
{
+ return foil_key_to_binary_format(self, FOIL_KEY_BINARY_FORMAT_DEFAULT);
+}
+
+GBytes*
+foil_key_to_binary_format(
+ FoilKey* self,
+ FoilKeyBinaryFormat format) /* Since 1.0.26 */
+{
GBytes* bytes = NULL;
if (G_LIKELY(self)) {
FoilKeyClass* klass = FOIL_KEY_GET_CLASS(self);
- bytes = klass->fn_to_bytes(self);
+ bytes = klass->fn_to_bytes(self, format);
}
return bytes;
}
@@ -496,7 +504,7 @@
FoilKey* self)
{
FoilKeyClass* klass = FOIL_KEY_GET_CLASS(self);
- GBytes* bytes = klass->fn_to_bytes(self);
+ GBytes* bytes = klass->fn_to_bytes(self, FOIL_KEY_BINARY_FORMAT_DEFAULT);
GBytes* fingerprint = foil_digest_bytes(FOIL_DIGEST_MD5, bytes);
GASSERT(!self->priv->fingerprint);
g_bytes_unref(bytes);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/foil_key_aes.c
^
|
@@ -1,29 +1,31 @@
/*
- * Copyright (C) 2016-2020 by Slava Monich
+ * Copyright (C) 2016-2022 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
@@ -183,7 +185,7 @@
FOIL_ERROR_KEY_UNRECOGNIZED_FORMAT,
"Unsupported AES%d key format", klass->size*8));
}
- GWARN("Unsupported AES%d key format", klass->size*8);
+ GDEBUG("Unsupported AES%d key format", klass->size*8);
return NULL;
}
}
@@ -209,10 +211,9 @@
static
GBytes*
-foil_key_aes_to_bytes(
- FoilKey* key)
+foil_key_aes_default_bytes(
+ FoilKeyAes* self)
{
- FoilKeyAes* self = FOIL_KEY_AES_(key);
FoilKeyAesClass* klass = FOIL_KEY_AES_GET_CLASS(self);
guint8* bytes = g_malloc(klass->size + FOIL_AES_BLOCK_SIZE);
memcpy(bytes, self->key, klass->size);
@@ -221,6 +222,23 @@
}
static
+GBytes*
+foil_key_aes_to_bytes(
+ FoilKey* key,
+ FoilKeyBinaryFormat format)
+{
+ switch (format) {
+ case FOIL_KEY_BINARY_FORMAT_DEFAULT:
+ return foil_key_aes_default_bytes(FOIL_KEY_AES_(key));
+ case FOIL_KEY_BINARY_FORMAT_RSA_SSH:
+ case FOIL_KEY_EXPORT_FORMAT_RSA_PKCS1:
+ break;
+ }
+ /* Invalid/unsupported format */
+ return NULL;
+}
+
+static
FoilKey*
foil_key_aes_set_iv(
FoilKey* key,
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/foil_key_des.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019-2021 by Slava Monich
+ * Copyright (C) 2019-2022 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
@@ -269,10 +269,9 @@
static
GBytes*
-foil_key_des_to_bytes(
- FoilKey* key)
+foil_key_des_default_bytes(
+ FoilKeyDes* self)
{
- FoilKeyDes* self = FOIL_KEY_DES_(key);
guint8* bytes;
gsize size = FOIL_DES_IV_SIZE + FOIL_DES_KEY_SIZE;
if (self->key2) {
@@ -296,6 +295,23 @@
}
static
+GBytes*
+foil_key_des_to_bytes(
+ FoilKey* key,
+ FoilKeyBinaryFormat format)
+{
+ switch (format) {
+ case FOIL_KEY_BINARY_FORMAT_DEFAULT:
+ return foil_key_des_default_bytes(FOIL_KEY_DES_(key));
+ case FOIL_KEY_BINARY_FORMAT_RSA_SSH:
+ case FOIL_KEY_EXPORT_FORMAT_RSA_PKCS1:
+ break;
+ }
+ /* Invalid/unsupported format */
+ return NULL;
+}
+
+static
FoilKey*
foil_key_des_set_iv(
FoilKey* key,
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/foil_key_p.h
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2022 by Slava Monich
+ * Copyright (C) 2016-2022 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
@@ -51,7 +51,7 @@
GHashTable* param, GError** error);
FoilKey* (*fn_set_iv)(FoilKey* key1, const void* iv, gsize len);
gboolean (*fn_equal)(FoilKey* key1, FoilKey* key2);
- GBytes* (*fn_to_bytes)(FoilKey* key);
+ GBytes* (*fn_to_bytes)(FoilKey* key, FoilKeyBinaryFormat format);
gboolean (*fn_export)(FoilKey* key, FoilOutput* out,
FoilKeyExportFormat format, GHashTable* param, GError** error);
GBytes* (*fn_fingerprint)(FoilKey* key);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/foil_key_rsa_private.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2021 by Slava Monich <slava@monich.com>
+ * Copyright (C) 2016-2022 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
@@ -35,6 +35,7 @@
#include "foil_key_rsa_private.h"
#include "foil_key_rsa_public.h"
#include "foil_key_aes.h"
+#include "foil_kdf.h"
#include "foil_random.h"
#include "foil_cipher.h"
#include "foil_digest.h"
@@ -191,13 +192,29 @@
static
GBytes*
-foil_key_rsa_private_to_bytes(
- FoilKey* key)
+foil_key_rsa_private_bytes_pkcs1(
+ FoilKeyRsaPrivate* self)
{
- FoilKeyRsaPrivate* self = FOIL_KEY_RSA_PRIVATE_(key);
return foil_key_rsa_private_data_to_bytes(self->data);
}
+static
+GBytes*
+foil_key_rsa_private_to_bytes(
+ FoilKey* key,
+ FoilKeyBinaryFormat format)
+{
+ switch (format) {
+ case FOIL_KEY_BINARY_FORMAT_DEFAULT:
+ case FOIL_KEY_EXPORT_FORMAT_RSA_PKCS1:
+ return foil_key_rsa_private_bytes_pkcs1(FOIL_KEY_RSA_PRIVATE_(key));
+ case FOIL_KEY_BINARY_FORMAT_RSA_SSH:
+ break;
+ }
+ /* Invalid/unsupported format */
+ return NULL;
+}
+
/*
* AlgorithmIdentifier is defined in RFC 5280 as follows:
*
@@ -446,7 +463,6 @@
return decrypted;
}
-/* PBKDF2 defined in RFC 2898 */
static
GBytes*
foil_key_rsa_private_pbkdf2(
@@ -457,64 +473,15 @@
GType digest,
FoilBytes* iv)
{
- const gsize hlen = foil_digest_type_size(digest);
- const gsize pass_len = pass ? strlen(pass) : 0;
- FoilHmac* tmpl = foil_hmac_new(digest, pass, pass_len);
- FoilHmac* hmac = foil_hmac_clone(tmpl);
const gsize key_size = bits/8;
- const guint total = key_size + iv->len;
+ const gsize total = key_size + iv->len;
guint8* data = g_malloc(total);
- guint8* ptr = data;
- gsize bytesleft = key_size;
- gsize i = 1;
-
- while (bytesleft > 0) {
- const gsize cplen = MIN(bytesleft, hlen);
- const guint8* h;
- guint8 itmp[4];
- GBytes* b;
- gsize j;
-
- itmp[0] = (unsigned char)((i >> 24) & 0xff);
- itmp[1] = (unsigned char)((i >> 16) & 0xff);
- itmp[2] = (unsigned char)((i >> 8) & 0xff);
- itmp[3] = (unsigned char)(i & 0xff);
-
- /* First time doesn't need a copy, it's already a clone */
- if (ptr != data) {
- foil_hmac_copy(hmac, tmpl);
- }
- foil_hmac_update(hmac, salt->val, salt->len);
- foil_hmac_update(hmac, itmp, 4);
-
- b = g_bytes_ref(foil_hmac_finish(hmac));
- h = g_bytes_get_data(b, NULL);
- memcpy(ptr, h, cplen);
-
- for (j = 1; j < count; j++) {
- gsize k;
-
- foil_hmac_copy(hmac, tmpl);
- foil_hmac_update(hmac, h, hlen);
-
- g_bytes_unref(b);
- b = g_bytes_ref(foil_hmac_finish(hmac));
- h = g_bytes_get_data(b, NULL);
-
- for (k = 0; k < cplen; k++) {
- ptr[k] ^= h[k];
- }
- }
-
- g_bytes_unref(b);
- bytesleft -= cplen;
- ptr += cplen;
- i++;
- }
+ GBytes* key = foil_kdf_pbkdf2(digest, pass, pass ? strlen(pass) : 0,
+ salt, count, key_size);
- foil_hmac_unref(hmac);
- foil_hmac_unref(tmpl);
- memcpy(ptr, iv->val, iv->len);
+ memcpy(data, g_bytes_get_data(key, NULL), key_size);
+ memcpy(data + key_size, iv->val, iv->len);
+ g_bytes_unref(key);
return g_bytes_new_take(data, total);
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/foil_key_rsa_public.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2021 by Slava Monich <slava@monich.com>
+ * Copyright (C) 2016-2022 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
@@ -174,7 +174,7 @@
static
GBytes*
-foil_key_rsa_public_data_to_bytes(
+foil_key_rsa_public_data_ssh_rsa(
const FoilKeyRsaPublicData* data)
{
GBytes* bytes = NULL;
@@ -192,15 +192,6 @@
}
static
-GBytes*
-foil_key_rsa_public_to_bytes(
- FoilKey* key)
-{
- FoilKeyRsaPublic* self = FOIL_KEY_RSA_PUBLIC_(key);
- return foil_key_rsa_public_data_to_bytes(self->data);
-}
-
-static
gboolean
foil_key_rsa_public_parse_ssh_rsa_binary(
FoilKeyRsaPublicData* key,
@@ -261,7 +252,9 @@
}
/*
- * Format defined in RFC 2313:
+ * PKCS #1
+ *
+ * https://www.ietf.org/rfc/rfc3447 (Appendix A)
*
* RSAPublicKey ::= SEQUENCE {
* modulus INTEGER, -- n
@@ -269,7 +262,7 @@
*/
static
gboolean
-foil_key_rsa_public_parse_asn1(
+foil_key_rsa_public_parse_pkcs1(
FoilKeyRsaPublicData* key,
const FoilBytes* bytes)
{
@@ -306,6 +299,24 @@
return NULL;
}
+static
+GBytes*
+foil_key_rsa_public_to_bytes(
+ FoilKey* key,
+ FoilKeyBinaryFormat format)
+{
+ FoilKeyRsaPublic* self = FOIL_KEY_RSA_PUBLIC_(key);
+ switch (format) {
+ case FOIL_KEY_BINARY_FORMAT_DEFAULT: /* fallthrough */
+ case FOIL_KEY_BINARY_FORMAT_RSA_SSH:
+ return foil_key_rsa_public_data_ssh_rsa(self->data);
+ case FOIL_KEY_EXPORT_FORMAT_RSA_PKCS1:
+ return foil_key_rsa_public_data_to_asn1(self->data);
+ }
+ /* Invalid/unsupported format */
+ return NULL;
+}
+
/*
* Format defined in RFC 5208:
*
@@ -345,7 +356,7 @@
if (foil_asn1_parse_object_id(&aid, &oid) &&
foil_bytes_equal(&oid, &oid_rsa) &&
foil_asn1_parse_bit_string(&pos, &bits, &unused) && !unused) {
- return foil_key_rsa_public_parse_asn1(key, &bits);
+ return foil_key_rsa_public_parse_pkcs1(key, &bits);
}
}
}
@@ -449,7 +460,8 @@
if (foil_key_rsa_public_parse_ssh_rsa_text(&key, &data, &pool) ||
foil_key_rsa_public_parse_pkcs8(&key, &data, &pool) ||
foil_key_rsa_public_parse_rfc4716(&key, &data, &pool) ||
- foil_key_rsa_public_parse_ssh_rsa_binary(&key, &data)) {
+ foil_key_rsa_public_parse_ssh_rsa_binary(&key, &data) ||
+ foil_key_rsa_public_parse_pkcs1(&key, &data)) {
FoilKeyRsaPublic* pub = g_object_new(G_TYPE_FROM_CLASS(klass), NULL);
foil_key_rsa_public_set_data(pub, &key);
g_clear_error(error);
@@ -460,7 +472,7 @@
FOIL_ERROR_KEY_UNRECOGNIZED_FORMAT,
"Unrecognized RSA public key format"));
}
- GWARN("Unsupported RSA public key format");
+ GDEBUG("Unsupported RSA public key format");
}
foil_pool_drain(&pool);
return result;
@@ -478,7 +490,7 @@
gboolean ok = foil_output_write_all(out, ssh_rsa_text_prefix,
sizeof(ssh_rsa_text_prefix)) && foil_output_write_all(out, &space, 1);
if (ok) {
- GBytes* bytes = foil_key_rsa_public_data_to_bytes(self->data);
+ GBytes* bytes = foil_key_rsa_public_data_ssh_rsa(self->data);
FoilOutput* base64 = foil_output_base64_new(out);
ok = foil_output_write_bytes_all(base64, bytes) &&
foil_output_flush(base64);
@@ -517,7 +529,7 @@
}
}
if (ok) {
- GBytes* bytes = foil_key_rsa_public_data_to_bytes(self->data);
+ GBytes* bytes = foil_key_rsa_public_data_ssh_rsa(self->data);
FoilOutput* base64 = foil_output_base64_new_full(out, 0, 70);
ok = foil_output_write_bytes_all(base64, bytes) &&
foil_output_flush(base64);
@@ -641,7 +653,7 @@
foil_key_rsa_public_data_fingerprint(
const FoilKeyRsaPublicData* data)
{
- GBytes* bytes = foil_key_rsa_public_data_to_bytes(data);
+ GBytes* bytes = foil_key_rsa_public_data_ssh_rsa(data);
GBytes* fingerprint = foil_digest_bytes(FOIL_DIGEST_MD5, bytes);
g_bytes_unref(bytes);
return fingerprint;
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/foil_output.c
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2016-2018 by Slava Monich
+ * Copyright (C) 2016-2022 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
@@ -102,7 +107,7 @@
gsize size;
const void* data = g_bytes_get_data(bytes, &size);
if (size > 0) {
- const gsize written = out->fn->fn_write(out, data, size);
+ const gssize written = out->fn->fn_write(out, data, size);
if (written > 0) {
GASSERT((gsize)written <= size);
out->bytes_written += written;
@@ -126,7 +131,7 @@
gsize size;
const void* data = g_bytes_get_data(bytes, &size);
if (size > 0) {
- const gsize written = out->fn->fn_write(out, data, size);
+ const gssize written = out->fn->fn_write(out, data, size);
if (written > 0) {
GASSERT((gsize)written <= size);
out->bytes_written += written;
@@ -148,7 +153,7 @@
*/
guint
foil_output_write_eol(
- FoilOutput* out)
+ FoilOutput* out) /* Since 1.0.9 */
{
static const char eol = '\n';
gssize written = foil_output_write(out, &eol, 1);
@@ -156,6 +161,14 @@
}
gboolean
+foil_output_write_byte(
+ FoilOutput* out,
+ guint8 byte) /* Since 1.0.27 */
+{
+ return foil_output_write(out, &byte, 1) == 1;
+}
+
+gboolean
foil_output_flush(
FoilOutput* out)
{
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/foil_output_cipher.c
^
|
@@ -0,0 +1,260 @@
+/*
+ * Copyright (C) 2022 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.
+ *
+ * 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
+ * any official policies, either expressed or implied.
+ */
+
+#include "foil_cipher.h"
+#include "foil_digest_p.h"
+#include "foil_hmac.h"
+#include "foil_output_p.h"
+
+#include <gutil_macros.h>
+
+/* Logging */
+#define GLOG_MODULE_NAME foil_log_output
+#include "foil_log_p.h"
+
+typedef struct foil_output_cipher {
+ FoilOutput parent;
+ FoilOutput* out;
+ FoilCipher* cipher;
+ gsize in_block_size;
+ gsize in_block_used;
+ guint8* in_block;
+ guint8* out_block;
+ void* digest;
+ FoilDigestGenericUpdateFunc digest_update;
+ FoilDigestGenericUnrefFunc digest_unref;
+} FoilOutputCipher;
+
+static
+gssize
+foil_output_cipher_write(
+ FoilOutput* out,
+ const void* data,
+ gsize size)
+{
+ FoilOutputCipher* self = G_CAST(out, FoilOutputCipher, parent);
+ const guint8* ptr = data;
+ gsize left = size;
+
+ while (self->in_block_used + left >= self->in_block_size) {
+ int encrypted;
+
+ if (self->in_block_used) {
+ const guint remaining = self->in_block_size - self->in_block_used;
+
+ memcpy(self->in_block + self->in_block_used, ptr, remaining);
+ encrypted = foil_cipher_step(self->cipher, self->in_block,
+ self->out_block);
+ self->digest_update(self->digest, self->in_block,
+ self->in_block_size);
+ self->in_block_used = 0;
+ left -= remaining;
+ ptr += remaining;
+ } else {
+ encrypted = foil_cipher_step(self->cipher, ptr, self->out_block);
+ self->digest_update(self->digest, ptr, self->in_block_size);
+ left -= self->in_block_size;
+ ptr += self->in_block_size;
+ }
+
+ if (encrypted < 0 || !foil_output_write_all(self->out,
+ self->out_block, encrypted)) {
+ return -1;
+ }
+ }
+
+ /* Stash the remaining non-encrypted bytes */
+ if (left > 0) {
+ if (!self->in_block) {
+ self->in_block = g_malloc(self->in_block_size);
+ }
+ memcpy(self->in_block + self->in_block_used, ptr, left);
+ self->in_block_used += left;
+ }
+
+ return size;
+}
+
+static
+gboolean
+foil_output_cipher_finish(
+ FoilOutputCipher* self)
+{
+ const int nout = foil_cipher_finish(self->cipher, self->in_block,
+ self->in_block_used, self->out_block);
+ const gboolean ok = ((nout == 0) || ((nout > 0) &&
+ foil_output_write_all(self->out, self->out_block, nout)));
+
+ /* Leave self->out to the caller */
+ self->digest_update(self->digest, self->in_block, self->in_block_used);
+ self->digest_unref(self->digest);
+ foil_cipher_unref(self->cipher);
+ g_free(self->in_block);
+ g_free(self->out_block);
+ self->in_block_used = 0;
+ self->in_block = NULL;
+ self->out_block = NULL;
+ self->cipher = NULL;
+ return ok;
+}
+
+static
+gboolean
+foil_output_cipher_flush(
+ FoilOutput* out)
+{
+ return TRUE;
+}
+
+static
+gboolean
+foil_output_cipher_reset(
+ FoilOutput* out)
+{
+ return FALSE;
+}
+
+static
+GBytes*
+foil_output_cipher_to_bytes(
+ FoilOutput* out)
+{
+ FoilOutputCipher* self = G_CAST(out, FoilOutputCipher, parent);
+ GBytes* bytes;
+
+ if (foil_output_cipher_finish(self)) {
+ bytes = foil_output_free_to_bytes(self->out);
+ } else {
+ foil_output_close(self->out);
+ foil_output_unref(self->out);
+ bytes = NULL;
+ }
+ self->out = NULL;
+ return bytes;
+}
+
+static
+void
+foil_output_cipher_close(
+ FoilOutput* out)
+{
+ FoilOutputCipher* self = G_CAST(out, FoilOutputCipher, parent);
+
+ foil_output_cipher_finish(self);
+ foil_output_close(self->out);
+ foil_output_unref(self->out);
+ self->out = NULL;
+}
+
+static
+void
+foil_output_cipher_free(
+ FoilOutput* out)
+{
+ g_slice_free(FoilOutputCipher, G_CAST(out, FoilOutputCipher, parent));
+}
+
+static
+FoilOutput*
+foil_output_cipher_internal_new(
+ FoilOutput* out,
+ FoilCipher* cipher,
+ gsize in_size,
+ gsize out_size,
+ void* digest_ref,
+ FoilDigestGenericUpdateFunc digest_update,
+ FoilDigestGenericUnrefFunc digest_unref)
+{
+ static const FoilOutputFunc foil_output_cipher_fn = {
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/foil_output_cipher_mem.c
^
|
@@ -0,0 +1,287 @@
+/*
+ * Copyright (C) 2022 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.
+ *
+ * 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
+ * any official policies, either expressed or implied.
+ */
+
+#include "foil_cipher.h"
+#include "foil_digest_p.h"
+#include "foil_hmac.h"
+#include "foil_output_p.h"
+
+#include <gutil_macros.h>
+
+/* Logging */
+#define GLOG_MODULE_NAME foil_log_output
+#include "foil_log_p.h"
+
+typedef struct foil_output_cipher_mem {
+ FoilOutput parent;
+ FoilCipher* cipher;
+ GByteArray* buf;
+ gsize offset;
+ gsize out_block_size;
+ gsize in_block_size;
+ gsize in_block_used;
+ guint8* in_block;
+ void* digest;
+ FoilDigestGenericUpdateFunc digest_update;
+ FoilDigestGenericUnrefFunc digest_unref;
+} FoilOutputCipherMem;
+
+static
+gssize
+foil_output_cipher_mem_write(
+ FoilOutput* out,
+ const void* data,
+ gsize size)
+{
+ FoilOutputCipherMem* self = G_CAST(out, FoilOutputCipherMem, parent);
+ GByteArray* buf = self->buf;
+ const guint8* ptr = data;
+ gsize left = size;
+
+ while (self->in_block_used + left >= self->in_block_size) {
+ const guint prev_len = buf->len;
+ const void* in_block;
+ int nout;
+
+ if (self->in_block_used) {
+ const guint remaining = self->in_block_size - self->in_block_used;
+
+ in_block = self->in_block;
+ memcpy(self->in_block + self->in_block_used, ptr, remaining);
+ self->in_block_used = 0;
+ left -= remaining;
+ ptr += remaining;
+ } else {
+ /* Can write directly into the output buffer */
+ in_block = ptr;
+ left -= self->in_block_size;
+ ptr += self->in_block_size;
+ }
+
+ g_byte_array_set_size(buf, prev_len + self->out_block_size);
+ nout = foil_cipher_step(self->cipher, in_block, buf->data + prev_len);
+ if (nout < 0) {
+ g_byte_array_set_size(buf, prev_len);
+ return -1;
+ } else {
+ g_byte_array_set_size(buf, prev_len + nout);
+ }
+ }
+
+ /* Stash the remaining non-encrypted bytes */
+ if (left > 0) {
+ if (!self->in_block) {
+ self->in_block = g_malloc(self->in_block_size);
+ }
+ memcpy(self->in_block + self->in_block_used, ptr, left);
+ self->in_block_used += left;
+ }
+
+ self->digest_update(self->digest, data, size);
+ return size;
+}
+
+static
+gboolean
+foil_output_cipher_mem_finish(
+ FoilOutputCipherMem* self)
+{
+ GByteArray* buf = self->buf;
+ const guint prev_len = buf->len;
+ int nout;
+
+ /* Cipher the remaining data */
+ g_byte_array_set_size(buf, prev_len + self->out_block_size);
+ nout = foil_cipher_finish(self->cipher, self->in_block,
+ self->in_block_used, buf->data + prev_len);
+ if (nout < 0) {
+ g_byte_array_set_size(buf, prev_len);
+ } else {
+ g_byte_array_set_size(buf, prev_len + nout);
+ }
+
+ /* Leave self->buf to the caller */
+ self->digest_unref(self->digest);
+ foil_cipher_unref(self->cipher);
+ g_free(self->in_block);
+ self->in_block_used = 0;
+ self->in_block = NULL;
+ self->cipher = NULL;
+ return (nout >= 0);
+}
+
+static
+gboolean
+foil_output_cipher_mem_flush(
+ FoilOutput* out)
+{
+ return TRUE;
+}
+
+static
+gboolean
+foil_output_cipher_mem_reset(
+ FoilOutput* out)
+{
+ /* There's no generic way to reset the cipher state */
+ return FALSE;
+}
+
+static
+GBytes*
+foil_output_cipher_mem_to_bytes(
+ FoilOutput* out)
+{
+ FoilOutputCipherMem* self = G_CAST(out, FoilOutputCipherMem, parent);
+ GByteArray* buf = self->buf;
+
+ if (!foil_output_cipher_mem_finish(self)) {
+ g_byte_array_unref(buf);
+ self->buf = NULL;
+ return NULL;
+ } else {
+ /* Avoid copying the data */
+ GBytes* bytes = g_byte_array_free_to_bytes(buf);
+
+ self->buf = NULL;
+ if (self->offset) {
+ GBytes* our_bytes = g_bytes_new_from_bytes(bytes, self->offset,
+ g_bytes_get_size(bytes) - self->offset);
+
+ g_bytes_unref(bytes);
+ return our_bytes;
+ } else {
+ return bytes;
+ }
+ }
+}
+
+static
+void
+foil_output_cipher_mem_close(
+ FoilOutput* out)
+{
+ FoilOutputCipherMem* self = G_CAST(out, FoilOutputCipherMem, parent);
+
+ foil_output_cipher_mem_finish(self);
+ g_byte_array_unref(self->buf);
+ self->buf = NULL;
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/foil_output_mem.c
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2016-2017 by Slava Monich
+ * Copyright (C) 2016-2022 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
@@ -49,6 +54,7 @@
gsize size)
{
FoilOutputMem* self = G_CAST(out, FoilOutputMem, parent);
+
g_byte_array_append(self->buf, buf, size);
return size;
}
@@ -77,20 +83,26 @@
FoilOutput* out)
{
FoilOutputMem* self = G_CAST(out, FoilOutputMem, parent);
- GBytes* bytes = g_byte_array_free_to_bytes(self->buf);
- const gsize size = g_bytes_get_size(bytes);
+ GByteArray* buf = self->buf;
+ const guint size = buf->len;
+
self->buf = NULL;
GASSERT(size == self->offset + out->bytes_written);
if (size != self->offset + out->bytes_written) {
- g_bytes_unref(bytes);
- bytes = NULL;
- } else if (self->offset) {
- GBytes* our_bytes = g_bytes_new_from_bytes(bytes,
- self->offset, size - self->offset);
- g_bytes_unref(bytes);
- bytes = our_bytes;
+ g_byte_array_unref(buf);
+ return NULL;
+ } else {
+ /* Avoid copying the data */
+ GBytes* bytes = g_byte_array_free_to_bytes(buf);
+ if (self->offset) {
+ GBytes* our_bytes = g_bytes_new_from_bytes(bytes,
+ self->offset, size - self->offset);
+ g_bytes_unref(bytes);
+ return our_bytes;
+ } else {
+ return bytes;
+ }
}
- return bytes;
}
static
@@ -99,6 +111,7 @@
FoilOutput* out)
{
FoilOutputMem* self = G_CAST(out, FoilOutputMem, parent);
+
g_byte_array_unref(self->buf);
self->buf = NULL;
}
@@ -109,8 +122,9 @@
FoilOutput* out)
{
FoilOutputMem* self = G_CAST(out, FoilOutputMem, parent);
+
GASSERT(!self->buf);
- g_slice_free(FoilOutputMem, self);
+ gutil_slice_free(self);
}
FoilOutput*
@@ -126,6 +140,7 @@
foil_output_mem_free /* fn_free */
};
FoilOutputMem* mem = g_slice_new0(FoilOutputMem);
+
if (buf) {
mem->buf = g_byte_array_ref(buf);
mem->offset = buf->len;
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/openssl/foil_openssl_digest_md5.c
^
|
@@ -46,17 +46,18 @@
MD5_CTX ctx;
} FoilOpensslDigestMD5;
-GType foil_openssl_digest_md5_get_type() FOIL_INTERNAL;
+#define THIS_TYPE foil_openssl_digest_md5_get_type()
+#define THIS(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, THIS_TYPE, \
+ FoilOpensslDigestMD5)
+GType THIS_TYPE FOIL_INTERNAL;
G_DEFINE_TYPE(FoilOpensslDigestMD5, foil_openssl_digest_md5, \
- FOIL_TYPE_DIGEST_MD5)
-#define FOIL_OPENSSL_DIGEST_MD5(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, \
- FOIL_DIGEST_MD5, FoilOpensslDigestMD5))
+ FOIL_TYPE_DIGEST_MD5)
GType
foil_impl_digest_md5_get_type()
{
- return foil_openssl_digest_md5_get_type();
+ return THIS_TYPE;
}
static
@@ -65,9 +66,15 @@
FoilDigest* digest,
FoilDigest* source)
{
- FoilOpensslDigestMD5* self = FOIL_OPENSSL_DIGEST_MD5(digest);
- FoilOpensslDigestMD5* other = FOIL_OPENSSL_DIGEST_MD5(source);
- self->ctx = other->ctx;
+ THIS(digest)->ctx = THIS(source)->ctx;
+}
+
+static
+void
+foil_openssl_digest_md5_reset(
+ FoilDigest* digest)
+{
+ MD5_Init(&(THIS(digest)->ctx));
}
static
@@ -77,8 +84,7 @@
const void* data,
size_t size)
{
- FoilOpensslDigestMD5* self = FOIL_OPENSSL_DIGEST_MD5(digest);
- MD5_Update(&self->ctx, data, size);
+ MD5_Update(&(THIS(digest)->ctx), data, size);
}
static
@@ -87,7 +93,8 @@
FoilDigest* digest,
void* md)
{
- FoilOpensslDigestMD5* self = FOIL_OPENSSL_DIGEST_MD5(digest);
+ FoilOpensslDigestMD5* self = THIS(digest);
+
if (md) {
MD5_Final(md, &self->ctx);
} else {
@@ -120,6 +127,7 @@
{
GASSERT(klass->size == MD5_DIGEST_LENGTH);
klass->fn_copy = foil_openssl_digest_md5_copy;
+ klass->fn_reset = foil_openssl_digest_md5_reset;
klass->fn_digest = foil_openssl_digest_md5_digest;
klass->fn_update = foil_openssl_digest_md5_update;
klass->fn_finish = foil_openssl_digest_md5_finish;
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/openssl/foil_openssl_digest_sha1.c
^
|
@@ -46,17 +46,18 @@
SHA_CTX ctx;
} FoilOpensslDigestSHA1;
-GType foil_openssl_digest_sha1_get_type() FOIL_INTERNAL;
+#define THIS_TYPE foil_openssl_digest_sha1_get_type()
+#define THIS(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, THIS_TYPE, \
+ FoilOpensslDigestSHA1)
+GType THIS_TYPE FOIL_INTERNAL;
G_DEFINE_TYPE(FoilOpensslDigestSHA1, foil_openssl_digest_sha1, \
- FOIL_TYPE_DIGEST_SHA1)
-#define FOIL_OPENSSL_DIGEST_SHA1(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, \
- FOIL_DIGEST_SHA1, FoilOpensslDigestSHA1))
+ FOIL_TYPE_DIGEST_SHA1)
GType
foil_impl_digest_sha1_get_type()
{
- return foil_openssl_digest_sha1_get_type();
+ return THIS_TYPE;
}
static
@@ -65,9 +66,15 @@
FoilDigest* digest,
FoilDigest* source)
{
- FoilOpensslDigestSHA1* self = FOIL_OPENSSL_DIGEST_SHA1(digest);
- FoilOpensslDigestSHA1* other = FOIL_OPENSSL_DIGEST_SHA1(source);
- self->ctx = other->ctx;
+ THIS(digest)->ctx = THIS(source)->ctx;
+}
+
+static
+void
+foil_openssl_digest_sha1_reset(
+ FoilDigest* digest)
+{
+ SHA1_Init(&(THIS(digest)->ctx));
}
static
@@ -77,8 +84,7 @@
const void* data,
size_t size)
{
- FoilOpensslDigestSHA1* self = FOIL_OPENSSL_DIGEST_SHA1(digest);
- SHA1_Update(&self->ctx, data, size);
+ SHA1_Update(&(THIS(digest)->ctx), data, size);
}
static
@@ -87,7 +93,8 @@
FoilDigest* digest,
void* md)
{
- FoilOpensslDigestSHA1* self = FOIL_OPENSSL_DIGEST_SHA1(digest);
+ FoilOpensslDigestSHA1* self = THIS(digest);
+
if (G_LIKELY(md)) {
SHA1_Final(md, &self->ctx);
} else {
@@ -120,6 +127,7 @@
{
GASSERT(klass->size == SHA_DIGEST_LENGTH);
klass->fn_copy = foil_openssl_digest_sha1_copy;
+ klass->fn_reset = foil_openssl_digest_sha1_reset;
klass->fn_digest = foil_openssl_digest_sha1_digest;
klass->fn_update = foil_openssl_digest_sha1_update;
klass->fn_finish = foil_openssl_digest_sha1_finish;
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/openssl/foil_openssl_digest_sha256.c
^
|
@@ -46,17 +46,18 @@
SHA256_CTX ctx;
} FoilOpensslDigestSHA256;
-GType foil_openssl_digest_sha256_get_type() FOIL_INTERNAL;
+#define THIS_TYPE foil_openssl_digest_sha256_get_type()
+#define THIS(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, THIS_TYPE, \
+ FoilOpensslDigestSHA256)
+GType THIS_TYPE FOIL_INTERNAL;
G_DEFINE_TYPE(FoilOpensslDigestSHA256, foil_openssl_digest_sha256, \
- FOIL_TYPE_DIGEST_SHA256)
-#define FOIL_OPENSSL_DIGEST_SHA256(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, \
- FOIL_DIGEST_SHA256, FoilOpensslDigestSHA256))
+ FOIL_TYPE_DIGEST_SHA256)
GType
foil_impl_digest_sha256_get_type()
{
- return foil_openssl_digest_sha256_get_type();
+ return THIS_TYPE;
}
static
@@ -65,9 +66,15 @@
FoilDigest* digest,
FoilDigest* source)
{
- FoilOpensslDigestSHA256* self = FOIL_OPENSSL_DIGEST_SHA256(digest);
- FoilOpensslDigestSHA256* other = FOIL_OPENSSL_DIGEST_SHA256(source);
- self->ctx = other->ctx;
+ THIS(digest)->ctx = THIS(source)->ctx;
+}
+
+static
+void
+foil_openssl_digest_sha256_reset(
+ FoilDigest* digest)
+{
+ SHA256_Init(&(THIS(digest)->ctx));
}
static
@@ -77,8 +84,7 @@
const void* data,
size_t size)
{
- FoilOpensslDigestSHA256* self = FOIL_OPENSSL_DIGEST_SHA256(digest);
- SHA256_Update(&self->ctx, data, size);
+ SHA256_Update(&(THIS(digest)->ctx), data, size);
}
static
@@ -87,7 +93,8 @@
FoilDigest* digest,
void* md)
{
- FoilOpensslDigestSHA256* self = FOIL_OPENSSL_DIGEST_SHA256(digest);
+ FoilOpensslDigestSHA256* self = THIS(digest);
+
if (G_LIKELY(md)) {
SHA256_Final(md, &self->ctx);
} else {
@@ -120,6 +127,7 @@
{
GASSERT(klass->size == SHA256_DIGEST_LENGTH);
klass->fn_copy = foil_openssl_digest_sha256_copy;
+ klass->fn_reset = foil_openssl_digest_sha256_reset;
klass->fn_digest = foil_openssl_digest_sha256_digest;
klass->fn_update = foil_openssl_digest_sha256_update;
klass->fn_finish = foil_openssl_digest_sha256_finish;
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/openssl/foil_openssl_digest_sha512.c
^
|
@@ -44,17 +44,18 @@
SHA512_CTX ctx;
} FoilOpensslDigestSHA512;
-GType foil_openssl_digest_sha512_get_type() FOIL_INTERNAL;
+#define THIS_TYPE foil_openssl_digest_sha512_get_type()
+#define THIS(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, THIS_TYPE, \
+ FoilOpensslDigestSHA512))
+GType THIS_TYPE FOIL_INTERNAL;
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))
+ FOIL_TYPE_DIGEST_SHA512)
GType
foil_impl_digest_sha512_get_type()
{
- return foil_openssl_digest_sha512_get_type();
+ return THIS_TYPE;
}
static
@@ -63,9 +64,15 @@
FoilDigest* digest,
FoilDigest* source)
{
- FoilOpensslDigestSHA512* self = FOIL_OPENSSL_DIGEST_SHA512(digest);
- FoilOpensslDigestSHA512* other = FOIL_OPENSSL_DIGEST_SHA512(source);
- self->ctx = other->ctx;
+ THIS(digest)->ctx = THIS(source)->ctx;
+}
+
+static
+void
+foil_openssl_digest_sha512_reset(
+ FoilDigest* digest)
+{
+ SHA512_Init(&(THIS(digest)->ctx));
}
static
@@ -75,8 +82,7 @@
const void* data,
size_t size)
{
- FoilOpensslDigestSHA512* self = FOIL_OPENSSL_DIGEST_SHA512(digest);
- SHA512_Update(&self->ctx, data, size);
+ SHA512_Update(&(THIS(digest)->ctx), data, size);
}
static
@@ -85,7 +91,8 @@
FoilDigest* digest,
void* md)
{
- FoilOpensslDigestSHA512* self = FOIL_OPENSSL_DIGEST_SHA512(digest);
+ FoilOpensslDigestSHA512* self = THIS(digest);
+
if (G_LIKELY(md)) {
SHA512_Final(md, &self->ctx);
} else {
@@ -118,6 +125,7 @@
{
GASSERT(klass->size == SHA512_DIGEST_LENGTH);
klass->fn_copy = foil_openssl_digest_sha512_copy;
+ klass->fn_reset = foil_openssl_digest_sha512_reset;
klass->fn_digest = foil_openssl_digest_sha512_digest;
klass->fn_update = foil_openssl_digest_sha512_update;
klass->fn_finish = foil_openssl_digest_sha512_finish;
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/openssl/foil_openssl_key_rsa_private.c
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2016-2019 by Slava Monich
+ * Copyright (C) 2016-2022 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
@@ -34,6 +39,8 @@
#define GLOG_MODULE_NAME foil_log_key
#include "foil_log_p.h"
+#define FOIL_RSA_FIELD(rsa,x) foil_openssl_rsa_get_##x(rsa)
+
typedef FoilKeyRsaPrivateClass FoilOpensslKeyRsaPrivateClass;
G_DEFINE_TYPE(FoilOpensslKeyRsaPrivate, foil_openssl_key_rsa_private, \
FOIL_TYPE_KEY_RSA_PRIVATE);
@@ -49,14 +56,10 @@
FoilKeyRsaPrivate* key,
RSA* rsa)
{
- FOIL_RSA_KEY_SET_BN(rsa, n, key->data);
- FOIL_RSA_KEY_SET_BN(rsa, e, key->data);
- FOIL_RSA_KEY_SET_BN(rsa, d, key->data);
- FOIL_RSA_KEY_SET_BN(rsa, p, key->data);
- FOIL_RSA_KEY_SET_BN(rsa, q, key->data);
- FOIL_RSA_KEY_SET_BN(rsa, dmp1, key->data);
- FOIL_RSA_KEY_SET_BN(rsa, dmq1, key->data);
- FOIL_RSA_KEY_SET_BN(rsa, iqmp, key->data);
+ const FoilKeyRsaPrivateData* data = key->data;
+ foil_openssl_rsa_set_key(rsa, &data->n, &data->e, &data->d);
+ foil_openssl_rsa_set_factors(rsa, &data->p, &data->q);
+ foil_openssl_rsa_set_params(rsa, &data->dmp1, &data->dmq1, &data->iqmp);
}
static
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/openssl/foil_openssl_key_rsa_public.c
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2016-2019 by Slava Monich
+ * Copyright (C) 2016-2022 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
@@ -40,8 +45,8 @@
FoilKeyRsaPublic* key,
RSA* rsa)
{
- FOIL_RSA_KEY_SET_BN(rsa, n, key->data);
- FOIL_RSA_KEY_SET_BN(rsa, e, key->data);
+ const FoilKeyRsaPublicData* data = key->data;
+ foil_openssl_rsa_set_key(rsa, &data->n, &data->e, NULL);
}
/*
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/openssl/foil_openssl_rsa.c
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2016-2019 by Slava Monich
+ * Copyright (C) 2016-2022 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
@@ -30,16 +35,17 @@
#include "foil_openssl_rsa.h"
/*
- * Originally, struct rsa_st was public then it was made opaque then it
- * started to mutate. Binary compatibility - what's that? Never heard of it!
+ * In OpenSSL 1.0 struct rsa_st was public and there were no RSA_get0_xxx
+ * and RSA_set0_xxx accessors. We use the accessors when they are* available,
+ * and only if they are not there, access the fields directly (which hopefully
+ * means that we are linked against OpenSSL 1.0)
*/
-#if GLIB_SIZEOF_LONG != 4
-typedef struct rsa_st_v1 {
+typedef struct rsa_st_1_0 {
int pad;
long version;
- const RSA_METHOD* meth;
- ENGINE* engine;
+ void* meth;
+ void* engine;
BIGNUM* n;
BIGNUM* e;
BIGNUM* d;
@@ -48,266 +54,227 @@
BIGNUM* dmp1;
BIGNUM* dmq1;
BIGNUM* iqmp;
-} RSA_V1;
-# define CHECK_RSA_V1
-#else
-# undef CHECK_RSA_V1
-#endif
+} RSA_1_0;
-typedef struct rsa_st_v2 {
- int pad;
- guint32 version;
- const RSA_METHOD* meth;
- ENGINE* engine;
- BIGNUM* n;
- BIGNUM* e;
- BIGNUM* d;
- BIGNUM* p;
- BIGNUM* q;
- BIGNUM* dmp1;
- BIGNUM* dmq1;
- BIGNUM* iqmp;
-} RSA_V2;
-
-#ifdef CHECK_RSA_V1
-static
-RSA_V1*
-foil_openssl_rsa_v1(
- const RSA* rsa)
-{
- RSA_V1* v1 = (void*)rsa;
- return (!v1->version && v1->meth && !v1->engine) ? v1 : NULL;
-}
-#endif /* CHECK_RSA_V1 */
-
-static
-RSA_V2*
-foil_openssl_rsa_v2(
- const RSA* rsa)
-{
- RSA_V2* v2 = (void*)rsa;
- return (!v2->version && v2->meth && !v2->engine) ? v2 : NULL;
-}
-
-#ifdef CHECK_RSA_V1
-# define FOIL_RSA_GET_FIELD_PTR(rsa,x) \
- RSA_V1* v1 = foil_openssl_rsa_v1(rsa); \
- if (v1) { \
- return &v1->x; \
- } else { \
- RSA_V2* v2 = foil_openssl_rsa_v2(rsa); \
- if (v2) return &v2->x; \
- } \
- return NULL
-#else
-# define FOIL_RSA_GET_FIELD_PTR(rsa,x) \
- RSA_V2* v2 = foil_openssl_rsa_v2(rsa); \
- return v2 ? &v2->x : NULL
-#endif
-
-static
-BIGNUM**
-foil_openssl_rsa_get_n_ptr(
- const RSA* rsa)
-{
- FOIL_RSA_GET_FIELD_PTR(rsa,n);
-}
-
-static
-BIGNUM**
-foil_openssl_rsa_get_e_ptr(
- const RSA* rsa)
-{
- FOIL_RSA_GET_FIELD_PTR(rsa,e);
-}
-
-static
-BIGNUM**
-foil_openssl_rsa_get_d_ptr(
- const RSA* rsa)
-{
- FOIL_RSA_GET_FIELD_PTR(rsa,d);
-}
-
-static
-BIGNUM**
-foil_openssl_rsa_get_p_ptr(
- const RSA* rsa)
-{
- FOIL_RSA_GET_FIELD_PTR(rsa,p);
-}
-
-static
-BIGNUM**
-foil_openssl_rsa_get_q_ptr(
- const RSA* rsa)
-{
- FOIL_RSA_GET_FIELD_PTR(rsa,q);
-}
+#define FOIL_WEAK_FN __attribute__((weak))
-static
-BIGNUM**
-foil_openssl_rsa_get_dmp1_ptr(
- const RSA* rsa)
-{
- FOIL_RSA_GET_FIELD_PTR(rsa,dmp1);
-}
-
-static
-BIGNUM**
-foil_openssl_rsa_get_dmq1_ptr(
- const RSA* rsa)
-{
- FOIL_RSA_GET_FIELD_PTR(rsa,dmq1);
-}
-
-static
-BIGNUM**
-foil_openssl_rsa_get_iqmp_ptr(
- const RSA* rsa)
-{
- FOIL_RSA_GET_FIELD_PTR(rsa,iqmp);
-}
+void
+RSA_get0_key(
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/libfoil/src/openssl/foil_openssl_rsa.h
^
|
@@ -39,18 +39,43 @@
#include "foil_key_rsa_public.h"
#include "foil_key_rsa_private.h"
+/*
+ * Accessors (if present at all) may have slightly different
+ * prototypes, with different const qualifiers.
+ */
+#define RSA_set0_key RSA_set0_key_
+#define RSA_set0_factors RSA_set0_factors_
+#define RSA_set0_crt_params RSA_set0_crt_params_
+#define RSA_get0_key RSA_get0_key_
+#define RSA_get0_factors RSA_get0_factors_
+#define RSA_get0_crt_params RSA_get0_crt_params_
+#define OPENSSL_SUPPRESS_DEPRECATED
+
#include <openssl/rsa.h>
#include <openssl/err.h>
+#undef RSA_set0_key
+#undef RSA_set0_factors
+#undef RSA_set0_crt_params
+#undef RSA_get0_key
+#undef RSA_get0_factors
+#undef RSA_get0_crt_params
+
+#if OPENSSL_API_LEVEL >= 30000
+# define RSA_CONST_PTR_3 const RSA*
+#else
+# define RSA_CONST_PTR_3 RSA*
+#endif
+
typedef FoilCipherClass FoilOpensslCipherRsaClass;
typedef struct foil_openssl_cipher_rsa {
FoilCipherSync sync;
int padding_size;
int padding;
RSA* rsa;
- RSA* (*dup)(RSA *rsa);
- int (*proc)(int flen, const unsigned char *from,
- unsigned char *to, RSA *rsa, int padding);
+ RSA* (*dup)(RSA_CONST_PTR_3 rsa);
+ int (*proc)(int flen, const unsigned char* from,
+ unsigned char* to, RSA* rsa, int padding);
} FoilOpensslCipherRsa;
GType foil_openssl_cipher_rsa_get_type(void) FOIL_INTERNAL;
@@ -117,57 +142,29 @@
/* Setters for RSA fields */
-const BIGNUM*
-foil_openssl_rsa_set_n(
- RSA* rsa,
- const FoilBytes* bytes)
- FOIL_INTERNAL;
-
-const BIGNUM*
-foil_openssl_rsa_set_e(
- RSA* rsa,
- const FoilBytes* bytes)
- FOIL_INTERNAL;
-
-const BIGNUM*
-foil_openssl_rsa_set_d(
- RSA* rsa,
- const FoilBytes* bytes)
- FOIL_INTERNAL;
-
-const BIGNUM*
-foil_openssl_rsa_set_p(
- RSA* rsa,
- const FoilBytes* bytes)
- FOIL_INTERNAL;
-
-const BIGNUM*
-foil_openssl_rsa_set_q(
- RSA* rsa,
- const FoilBytes* bytes)
- FOIL_INTERNAL;
-
-const BIGNUM*
-foil_openssl_rsa_set_dmp1(
+void
+foil_openssl_rsa_set_key(
RSA* rsa,
- const FoilBytes* bytes)
+ const FoilBytes* n,
+ const FoilBytes* e,
+ const FoilBytes* d)
FOIL_INTERNAL;
-const BIGNUM*
-foil_openssl_rsa_set_dmq1(
+void
+foil_openssl_rsa_set_factors(
RSA* rsa,
- const FoilBytes* bytes)
+ const FoilBytes* p,
+ const FoilBytes* q)
FOIL_INTERNAL;
-const BIGNUM*
-foil_openssl_rsa_set_iqmp(
+void
+foil_openssl_rsa_set_params(
RSA* rsa,
- const FoilBytes* bytes)
+ const FoilBytes* dmp1,
+ const FoilBytes* dmq1,
+ const FoilBytes* iqmp)
FOIL_INTERNAL;
-#define FOIL_RSA_FIELD(rsa,x) foil_openssl_rsa_get_##x(rsa)
-#define FOIL_RSA_KEY_SET_BN(rsa,x,data) foil_openssl_rsa_set_##x(rsa, &(data)->x)
-
#define FOIL_RSA_PKCS1_OAEP_PADDING_SIZE 42
#endif /* FOIL_OPENSSL_RSA_H */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/rpm/foil.spec
^
|
@@ -1,6 +1,6 @@
Name: libfoil
-Version: 1.0.25
+Version: 1.0.27
Release: 0
Summary: Yet another glib-style crypto API
Group: Development/Libraries
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/test/common/Makefile
^
|
@@ -129,9 +129,21 @@
endif
endif
-$(DEBUG_OBJS): | $(DEBUG_BUILD_DIR)
-$(RELEASE_OBJS): | $(RELEASE_BUILD_DIR)
-$(COVERAGE_OBJS): | $(COVERAGE_BUILD_DIR)
+DEBUG_DEPS += $(DEBUG_LIB)
+RELEASE_DEPS += $(RELEASE_LIB)
+COVERAGE_DEPS += $(COVERAGE_LIB)
+
+DEBUG_ORDER_DEPS += libfoil-debug
+RELEASE_ORDER_DEPS += libfoil-release
+COVERAGE_ORDER_DEPS += libfoil-coverage
+
+$(DEBUG_LIB): | libfoil-debug
+$(RELEASE_LIB): | libfoil-release
+$(COVERAGE_LIB): | libfoil-coverage
+
+$(DEBUG_EXE) $(DEBUG_OBJS): | $(DEBUG_BUILD_DIR) $(DEBUG_ORDER_DEPS)
+$(RELEASE_EXE) $(RELEASE_OBJS): | $(RELEASE_BUILD_DIR) $(RELEASE_ORDER_DEPS)
+$(COVERAGE_EXE) $(COVERAGE_OBJS): | $(COVERAGE_BUILD_DIR) $(COVERAGE_ORDER_DEPS)
#
# Rules
@@ -141,15 +153,11 @@
RELEASE_EXE = $(RELEASE_BUILD_DIR)/$(EXE)
COVERAGE_EXE = $(COVERAGE_BUILD_DIR)/$(EXE)
-DEBUG_DEPS += libfoil-debug $(DEBUG_EXE)
-RELEASE_DEPS += libfoil-release $(RELEASE_EXE)
-COVERAGE_DEPS += libfoil-coverage $(COVERAGE_EXE)
+debug: $(DEBUG_EXE)
-debug: $(DEBUG_DEPS)
+release: $(RELEASE_EXE)
-release: $(RELEASE_DEPS)
-
-coverage: $(COVERAGE_DEPS)
+coverage: $(COVERAGE_EXE)
clean:
rm -f *~
@@ -167,6 +175,15 @@
valgrind: test_banner debug
@G_DEBUG=gc-friendly G_SLICE=always-malloc valgrind --tool=memcheck --leak-check=full --show-possibly-lost=no $(DEBUG_EXE)
+libfoil-debug:
+ @make $(SUBMAKE_OPTS) -C $(LIB_DIR) debug
+
+libfoil-release:
+ @make $(SUBMAKE_OPTS) -C $(LIB_DIR) release
+
+libfoil-coverage:
+ @make $(SUBMAKE_OPTS) -C $(LIB_DIR) coverage
+
$(DEBUG_BUILD_DIR):
mkdir -p $@
@@ -216,23 +233,14 @@
$(CC) -c $(COVERAGE_CFLAGS) -MT"$@" -MF"$(@:%.o=%.d)" $< -o $@
endif
-$(DEBUG_EXE): $(DEBUG_LIB) $(DEBUG_BUILD_DIR) $(DEBUG_OBJS)
+$(DEBUG_EXE): $(DEBUG_BUILD_DIR) $(DEBUG_OBJS) $(DEBUG_DEPS)
$(LD) $(DEBUG_LDFLAGS) $(DEBUG_OBJS) $(DEBUG_LIBS) -o $@
-$(RELEASE_EXE): $(RELEASE_LIB) $(RELEASE_BUILD_DIR) $(RELEASE_OBJS)
+$(RELEASE_EXE): $(RELEASE_BUILD_DIR) $(RELEASE_OBJS) $(RELEASE_DEPS)
$(LD) $(RELEASE_LDFLAGS) $(RELEASE_OBJS) $(RELEASE_LIBS) -o $@
ifeq ($(KEEP_SYMBOLS),0)
strip $@
endif
-$(COVERAGE_EXE): $(COVERAGE_LIB) $(COVERAGE_BUILD_DIR) $(COVERAGE_OBJS)
+$(COVERAGE_EXE): $(COVERAGE_BUILD_DIR) $(COVERAGE_OBJS) $(COVERAGE_DEPS)
$(LD) $(COVERAGE_LDFLAGS) $(COVERAGE_OBJS) $(COVERAGE_LIBS) -o $@
-
-libfoil-debug:
- @make $(SUBMAKE_OPTS) -C $(LIB_DIR) debug
-
-libfoil-release:
- @make $(SUBMAKE_OPTS) -C $(LIB_DIR) release
-
-libfoil-coverage:
- @make $(SUBMAKE_OPTS) -C $(LIB_DIR) coverage
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/test/common/Makefile.foilmsg
^
|
@@ -6,17 +6,27 @@
LIBFOILMSG_DIR ?= ../../../libfoilmsg
+INCLUDES += -I$(LIBFOILMSG_DIR)/include -I$(LIBFOILMSG_DIR)/src
+
+DEBUG_ORDER_DEPS += libfoilmsg-debug
+RELEASE_ORDER_DEPS += libfoilmsg-release
+COVERAGE_ORDER_DEPS += libfoilmsg-coverage
+
DEBUG_LIBFOILMSG_FILE := $(shell $(QUIET_MAKE) -C $(LIBFOILMSG_DIR) print_debug_lib)
RELEASE_LIBFOILMSG_FILE := $(shell $(QUIET_MAKE) -C $(LIBFOILMSG_DIR) print_release_lib)
COVERAGE_LIBFOILMSG_FILE := $(shell $(QUIET_MAKE) -C $(LIBFOILMSG_DIR) print_coverage_lib)
-INCLUDES += -I$(LIBFOILMSG_DIR)/include -I$(LIBFOILMSG_DIR)/src
-DEBUG_LIBS += $(LIBFOILMSG_DIR)/$(DEBUG_LIBFOILMSG_FILE)
-RELEASE_LIBS += $(LIBFOILMSG_DIR)/$(RELEASE_LIBFOILMSG_FILE)
-COVERAGE_LIBS += $(LIBFOILMSG_DIR)/$(COVERAGE_LIBFOILMSG_FILE)
-DEBUG_DEPS += libfoilmsg-debug
-RELEASE_DEPS += libfoilmsg-release
-COVERAGE_DEPS += libfoilmsg-coverage
+DEBUG_FOILMSG_LIB += $(LIBFOILMSG_DIR)/$(DEBUG_LIBFOILMSG_FILE)
+RELEASE_FOILMSG_LIB += $(LIBFOILMSG_DIR)/$(RELEASE_LIBFOILMSG_FILE)
+COVERAGE_FOILMSG_LIB += $(LIBFOILMSG_DIR)/$(COVERAGE_LIBFOILMSG_FILE)
+
+DEBUG_LIBS += $(DEBUG_FOILMSG_LIB)
+RELEASE_LIBS += $(RELEASE_FOILMSG_LIB)
+COVERAGE_LIBS += $(COVERAGE_FOILMSG_LIB)
+
+DEBUG_DEPS += $(DEBUG_FOILMSG_LIB)
+RELEASE_DEPS += $(RELEASE_FOILMSG_LIB)
+COVERAGE_DEPS += $(COVERAGE_FOILMSG_LIB)
include $(COMMON_DIR)/Makefile
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/test/common/test_common.h
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2016-2018 by Slava Monich
+ * Copyright (C) 2016-2022 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
@@ -44,11 +49,6 @@
test_run(
void);
-GBytes*
-test_bytes_concat(
- GBytes* bytes1,
- GBytes* bytes2);
-
gboolean
test_bytes_equal(
GBytes* bytes,
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/test/common/test_main.c
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2016-2017 by Slava Monich
+ * Copyright (C) 2016-2022 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
@@ -48,34 +53,6 @@
return test_bytes_equal(bytes, str, strlen(str));
}
-GBytes*
-test_bytes_concat(
- GBytes* bytes1,
- GBytes* bytes2)
-{
- guint8* data;
- guint8* ptr;
- gsize size = 0;
- if (bytes1) {
- size += g_bytes_get_size(bytes1);
- }
- if (bytes2) {
- size += g_bytes_get_size(bytes2);
- }
- ptr = data = g_malloc(size);
- if (bytes1) {
- const gsize nbytes = g_bytes_get_size(bytes1);
- memcpy(ptr, g_bytes_get_data(bytes1, NULL), nbytes);
- ptr += nbytes;
- }
- if (bytes2) {
- const gsize nbytes = g_bytes_get_size(bytes2);
- memcpy(ptr, g_bytes_get_data(bytes2, NULL), nbytes);
- ptr += nbytes;
- }
- return g_bytes_new_take(data, size);
-}
-
int
test_run(
void)
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/test/libfoil/test_cavp_aes/test_cavp_aes.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2021 by Slava Monich
+ * Copyright (C) 2016-2022 by Slava Monich
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -246,7 +246,7 @@
test_cavp_aes_key(
const Test* test)
{
- GBytes* key_bytes = test_bytes_concat(test->key, test->iv);
+ GBytes* key_bytes = gutil_bytes_concat(test->key, test->iv, NULL);
GType key_type;
FoilKey* key;
switch (g_bytes_get_size(test->key)*8) {
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/test/libfoil/test_cavp_cmac/test_cavp_cmac.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 by Slava Monich
+ * Copyright (C) 2019-2022 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
@@ -265,7 +265,7 @@
test.Key3 = test_bytes_truncate(test.Key3, FOIL_DES_KEY_SIZE);
test.Msg = test_bytes_truncate(test.Msg, test.Mlen);
test.Mac = test_bytes_truncate(test.Mac, test.Tlen);
- tests = g_slist_append(tests, g_memdup(&test, sizeof(test)));
+ tests = g_slist_append(tests, gutil_memdup(&test, sizeof(test)));
memset(&test, 0, sizeof(test));
flags = 0;
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/test/libfoil/test_digest/test_digest.c
^
|
@@ -1,29 +1,31 @@
/*
- * Copyright (C) 2016-2021 by Slava Monich
+ * Copyright (C) 2016-2022 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
@@ -34,6 +36,8 @@
#include "foil_digest_p.h"
+#include <gutil_misc.h>
+
typedef struct test_digest {
const char* name;
GTestDataFunc fn;
@@ -44,6 +48,30 @@
guint output_size;
} TestDigest;
+/* Empty digests */
+#define empty_md5_data test_md5_data1
+static const guint8 empty_sha1_data[] = {
+ 0xda,0x39,0xa3,0xee,0x5e,0x6b,0x4b,0x0d,
+ 0x32,0x55,0xbf,0xef,0x95,0x60,0x18,0x90,
+ 0xaf,0xd8,0x07,0x09
+};
+static const guint8 empty_sha256_data[] = {
+ 0xe3,0xb0,0xc4,0x42,0x98,0xfc,0x1c,0x14,
+ 0x9a,0xfb,0xf4,0xc8,0x99,0x6f,0xb9,0x24,
+ 0x27,0xae,0x41,0xe4,0x64,0x9b,0x93,0x4c,
+ 0xa4,0x95,0x99,0x1b,0x78,0x52,0xb8,0x55
+};
+static const guint8 empty_sha512_data[] = {
+ 0xcf,0x83,0xe1,0x35,0x7e,0xef,0xb8,0xbd,
+ 0xf1,0x54,0x28,0x50,0xd6,0x6d,0x80,0x07,
+ 0xd6,0x20,0xe4,0x05,0x0b,0x57,0x15,0xdc,
+ 0x83,0xf4,0xa9,0x21,0xd3,0x6c,0xe9,0xce,
+ 0x47,0xd0,0xd1,0x3c,0x5d,0x85,0xf2,0xb0,
+ 0xff,0x83,0x18,0xd2,0x87,0x7e,0xec,0x2f,
+ 0x63,0xb9,0x31,0xbd,0x47,0x41,0x7a,0x81,
+ 0xa5,0x38,0x32,0x7a,0xf9,0x27,0xda,0x3e
+};
+
/* MD5 examples from http://www.ietf.org/rfc/rfc1321 */
#define MD5_TEST1 ""
@@ -220,11 +248,14 @@
static const guchar data[1] = { 1 };
GBytes* bytes = g_bytes_new_static(data, sizeof(data));
FoilDigest* md5 = foil_digest_new_md5();
+ int tmp;
+
g_assert(!foil_digest_type_size(0));
g_assert(!foil_digest_type_block_size(0));
g_assert(!foil_digest_type_name(0));
g_assert(!foil_digest_new(0));
g_assert(!foil_digest_clone(NULL));
+ g_assert(!foil_digest_reset(NULL));
g_assert(!foil_digest_ref(NULL));
g_assert(!foil_digest_size(NULL));
g_assert(!foil_digest_block_size(NULL));
@@ -236,6 +267,9 @@
g_assert(!foil_digest_data(0, NULL, sizeof(data)));
g_assert(!foil_digest_data(0, data, sizeof(data)));
g_assert(!foil_digest_data(0, data, 0));
+ g_assert(!foil_digest_data_buf(G_TYPE_OBJECT, NULL, 0, NULL));
+ g_assert(!foil_digest_data_buf(G_TYPE_OBJECT, NULL, 0, &tmp));
+ g_assert(!foil_digest_data_buf(FOIL_DIGEST_MD5, NULL, 0, NULL));
g_assert(!foil_digest_bytes(0, NULL));
g_assert(!foil_digest_bytes(0, bytes));
g_assert(!foil_digest_type_block_size(FOIL_TYPE_DIGEST));
@@ -250,6 +284,7 @@
foil_digest_update_bytes(NULL, bytes);
foil_digest_unref(NULL);
g_bytes_unref(bytes);
+ foil_digest_reset(md5);
foil_digest_unref(md5);
}
@@ -260,15 +295,19 @@
{
FoilDigest* d1 = foil_digest_new_md5();
FoilDigest* d2;
+ GBytes* md5_in = g_bytes_new_static(MD5_TEST2, strlen(MD5_TEST2));
GBytes* b1;
GBytes* b2;
/* Clone unfinished digest */
- foil_digest_update(d1, MD5_TEST2, strlen(MD5_TEST2));
+ g_assert(foil_digest_update_bytes(d1, md5_in));
d2 = foil_digest_clone(d1);
b1 = foil_digest_finish(d1);
b2 = foil_digest_finish(d2);
+ /* Finished digest is not updated */
+ g_assert(!foil_digest_update_bytes(d1, md5_in));
+
g_assert(g_bytes_equal(b1, b2));
g_assert(g_bytes_get_size(b1) == sizeof(test_md5_data2));
g_assert(!memcmp(g_bytes_get_data(b1, NULL), test_md5_data2,
@@ -279,9 +318,12 @@
/* Clone finished digest */
d1 = foil_digest_new_sha1();
- foil_digest_update(d1, SHA1_TEST1, strlen(SHA1_TEST1));
+ g_assert(foil_digest_update(d1, SHA1_TEST1, strlen(SHA1_TEST1)));
b1 = foil_digest_finish(d1);
+ /* Finished digest is not updated */
+ g_assert(!foil_digest_update(d1, SHA1_TEST1, strlen(SHA1_TEST1)));
+
d2 = foil_digest_clone(d1);
b2 = foil_digest_finish(d2);
@@ -292,6 +334,7 @@
foil_digest_unref(d1);
foil_digest_unref(d2);
+ g_bytes_unref(md5_in);
}
static
@@ -372,6 +415,39 @@
static
void
+test_reset(
+ gconstpointer param)
+{
+ const TestDigest* test = param;
+ const size_t input_len = strlen(test->input);
+ GType type = test->digest_type();
+ FoilDigest* digest = foil_digest_new(type);
+ GBytes* b1;
+ GBytes* b2;
+ int i;
+
+ for (i = 0; i < test->repeat_count; i++) {
+ foil_digest_update(digest, test->input, input_len);
+ }
+ b1 = g_bytes_ref(foil_digest_finish(digest));
+
+ g_assert(foil_digest_reset(digest));
+
+ for (i = 0; i < test->repeat_count; i++) {
+ foil_digest_update(digest, test->input, input_len);
+ }
+ b2 = foil_digest_finish(digest);
+
+ /* Results must be different but identical */
+ g_assert(b1 != b2);
+ g_assert(g_bytes_equal(b1, b2));
+
+ g_bytes_unref(b1);
+ foil_digest_unref(digest);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/test/libfoil/test_hmac/test_hmac.c
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2018 by Slava Monich
+ * Copyright (C) 2018-2022 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,22 +45,57 @@
FoilBytes output;
} TestHmac;
+/* Empty HMACs */
+
+static const guint8 empty_md5_output[] = {
+ 0x74,0xe6,0xf7,0x29,0x8a,0x9c,0x2d,0x16,
+ 0x89,0x35,0xf5,0x8c,0x00,0x1b,0xad,0x88
+};
+
+static const guint8 empty_sha1_output[] = {
+ 0xfb,0xdb,0x1d,0x1b,0x18,0xaa,0x6c,0x08,
+ 0x32,0x4b,0x7d,0x64,0xb7,0x1f,0xb7,0x63,
+ 0x70,0x69,0x0e,0x1d
+};
+
+static const guint8 empty_sha256_output[] = {
+ 0xb6,0x13,0x67,0x9a,0x08,0x14,0xd9,0xec,
+ 0x77,0x2f,0x95,0xd7,0x78,0xc3,0x5f,0xc5,
+ 0xff,0x16,0x97,0xc4,0x93,0x71,0x56,0x53,
+ 0xc6,0xc7,0x12,0x14,0x42,0x92,0xc5,0xad
+};
+
+static const guint8 empty_sha512_output[] = {
+ 0xb9,0x36,0xce,0xe8,0x6c,0x9f,0x87,0xaa,
+ 0x5d,0x3c,0x6f,0x2e,0x84,0xcb,0x5a,0x42,
+ 0x39,0xa5,0xfe,0x50,0x48,0x0a,0x6e,0xc6,
+ 0x6b,0x70,0xab,0x5b,0x1f,0x4a,0xc6,0x73,
+ 0x0c,0x6c,0x51,0x54,0x21,0xb3,0x27,0xec,
+ 0x1d,0x69,0x40,0x2e,0x53,0xdf,0xb4,0x9a,
+ 0xd7,0x38,0x1e,0xb0,0x67,0xb3,0x38,0xfd,
+ 0x7b,0x0c,0xb2,0x22,0x47,0x22,0x5d,0x47,
+};
+
/*
* Test vectors from:
*
* https://tools.ietf.org/rfc/rfc2202.txt (MD-5, SHA-1)
* https://tools.ietf.org/rfc/rfc2202.txt (SHA-256)
+ * https://tools.ietf.org/rfc/rfc4231.txt (SHA512)
*/
-#define test1_sha256_key test1_sha1_key
+#define test1_sha1_key test1_sha_key
+#define test1_sha256_key test1_sha_key
+#define test1_sha512_key test1_sha_key
#define test1_md5_data test1_data
#define test1_sha1_data test1_data
#define test1_sha256_data test1_data
+#define test1_sha512_data test1_data
static const guint8 test1_md5_key[] = {
0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,
0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b
};
-static const guint8 test1_sha1_key[] = {
+static const guint8 test1_sha_key[] = {
0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,
0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,
0x0b,0x0b,0x0b,0x0b
@@ -78,13 +118,25 @@
0x88,0x1d,0xc2,0x00,0xc9,0x83,0x3d,0xa7,
0x26,0xe9,0x37,0x6c,0x2e,0x32,0xcf,0xf7
};
+static const guint8 test1_sha512_output[] = {
+ 0x87,0xaa,0x7c,0xde,0xa5,0xef,0x61,0x9d,
+ 0x4f,0xf0,0xb4,0x24,0x1a,0x1d,0x6c,0xb0,
+ 0x23,0x79,0xf4,0xe2,0xce,0x4e,0xc2,0x78,
+ 0x7a,0xd0,0xb3,0x05,0x45,0xe1,0x7c,0xde,
+ 0xda,0xa8,0x33,0xb7,0xd6,0xb8,0xa7,0x02,
+ 0x03,0x8b,0x27,0x4e,0xae,0xa3,0xf4,0xe4,
+ 0xbe,0x9d,0x91,0x4e,0xeb,0x61,0xf1,0x70,
+ 0x2e,0x69,0x6c,0x20,0x3a,0x12,0x68,0x54
+};
#define test2_md5_key test2_key
#define test2_sha1_key test2_key
#define test2_sha256_key test2_key
+#define test2_sha512_key test2_key
#define test2_md5_data test2_data
#define test2_sha1_data test2_data
#define test2_sha256_data test2_data
+#define test2_sha512_data test2_data
static const guint8 test2_key[] = {
'J', 'e', 'f', 'e'
};
@@ -109,16 +161,29 @@
0x5a,0x00,0x3f,0x08,0x9d,0x27,0x39,0x83,
0x9d,0xec,0x58,0xb9,0x64,0xec,0x38,0x43
};
+static const guint8 test2_sha512_output[] = {
+ 0x16,0x4b,0x7a,0x7b,0xfc,0xf8,0x19,0xe2,
+ 0xe3,0x95,0xfb,0xe7,0x3b,0x56,0xe0,0xa3,
+ 0x87,0xbd,0x64,0x22,0x2e,0x83,0x1f,0xd6,
+ 0x10,0x27,0x0c,0xd7,0xea,0x25,0x05,0x54,
+ 0x97,0x58,0xbf,0x75,0xc0,0x5a,0x99,0x4a,
+ 0x6d,0x03,0x4f,0x65,0xf8,0xf0,0xe6,0xfd,
+ 0xca,0xea,0xb1,0xa3,0x4d,0x4a,0x6b,0x4b,
+ 0x63,0x6e,0x07,0x0a,0x38,0xbc,0xe7,0x37
+};
-#define test3_sha256_key test3_sha1_key
+#define test3_sha1_key test3_sha_key
+#define test3_sha256_key test3_sha_key
+#define test3_sha512_key test3_sha_key
#define test3_md5_data test3_data
#define test3_sha1_data test3_data
#define test3_sha256_data test3_data
+#define test3_sha512_data test3_data
static const guint8 test3_md5_key[] = {
0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,
0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa
};
-static const guint8 test3_sha1_key[] = {
+static const guint8 test3_sha_key[] = {
0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,
0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,
0xaa,0xaa,0xaa,0xaa
@@ -147,13 +212,25 @@
0x29,0x59,0x09,0x8b,0x3e,0xf8,0xc1,0x22,
0xd9,0x63,0x55,0x14,0xce,0xd5,0x65,0xfe
};
+static const guint8 test3_sha512_output[] = {
+ 0xfa,0x73,0xb0,0x08,0x9d,0x56,0xa2,0x84,
+ 0xef,0xb0,0xf0,0x75,0x6c,0x89,0x0b,0xe9,
+ 0xb1,0xb5,0xdb,0xdd,0x8e,0xe8,0x1a,0x36,
+ 0x55,0xf8,0x3e,0x33,0xb2,0x27,0x9d,0x39,
+ 0xbf,0x3e,0x84,0x82,0x79,0xa7,0x22,0xc8,
+ 0x06,0xb4,0x85,0xa4,0x7e,0x67,0xc8,0x07,
+ 0xb9,0x46,0xa3,0x37,0xbe,0xe8,0x94,0x26,
+ 0x74,0x27,0x88,0x59,0xe1,0x32,0x92,0xfb
+};
#define test4_md5_key test4_key
#define test4_sha1_key test4_key
#define test4_sha256_key test4_key
+#define test4_sha512_key test4_key
#define test4_md5_data test4_data
#define test4_sha1_data test4_data
#define test4_sha256_data test4_data
+#define test4_sha512_data test4_data
static const guint8 test4_key[] = {
0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,
0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,
@@ -184,16 +261,29 @@
0x85,0xf0,0xfa,0xa3,0xe5,0x78,0xf8,0x07,
0x7a,0x2e,0x3f,0xf4,0x67,0x29,0x66,0x5b
};
+static const guint8 test4_sha512_output[] = {
+ 0xb0,0xba,0x46,0x56,0x37,0x45,0x8c,0x69,
+ 0x90,0xe5,0xa8,0xc5,0xf6,0x1d,0x4a,0xf7,
+ 0xe5,0x76,0xd9,0x7f,0xf9,0x4b,0x87,0x2d,
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/test/libfoil/test_key_aes/test_key_aes.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2019 by Slava Monich
+ * Copyright (C) 2016-2022 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
@@ -168,6 +168,12 @@
FoilKey* key2 = foil_key_generate_new(type, FOIL_KEY_BITS_DEFAULT);
GBytes* bytes = foil_key_to_bytes(key2);
FoilKey* key3;
+
+ /* Only default format is valid for AES keys */
+ g_assert(!foil_key_to_binary_format(key1, FOIL_KEY_EXPORT_FORMAT_RSA_PKCS1));
+ g_assert(!foil_key_to_binary_format(key1, FOIL_KEY_BINARY_FORMAT_RSA_SSH));
+ g_assert(!foil_key_to_binary_format(key1, (FoilKeyBinaryFormat)-1));
+
g_assert(key1 && key2);
key3 = foil_key_new_from_bytes(G_TYPE_FROM_INSTANCE(key2), bytes);
g_assert(key3);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/test/libfoil/test_key_des/test_key_des.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2019 by Slava Monich
+ * Copyright (C) 2019-2022 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
@@ -130,6 +130,11 @@
FoilKey* deserialized = foil_key_new_from_bytes(FOIL_KEY_DES, serialized);
GError* error = NULL;
+ /* Only default format is valid for DES keys */
+ g_assert(!foil_key_to_binary_format(key, FOIL_KEY_EXPORT_FORMAT_RSA_PKCS1));
+ g_assert(!foil_key_to_binary_format(key, FOIL_KEY_BINARY_FORMAT_RSA_SSH));
+ g_assert(!foil_key_to_binary_format(key, (FoilKeyBinaryFormat)-1));
+
/* If IV is already zero, foil_key_set_iv works like foil_key_ref */
g_assert(foil_key_set_iv(key3, NULL, FOIL_DES_IV_SIZE) == key3);
foil_key_unref(key3);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/test/libfoil/test_key_rsa/test_key_rsa.c
^
|
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2019 by Slava Monich
+ * Copyright (C) 2016-2022 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
@@ -418,12 +418,39 @@
TestKeyRsaKeys keys;
GBytes* pub_data;
GBytes* priv_data;
+ GBytes* bytes;
FoilKey* pub2;
+ FoilKey* priv_key;
FoilPrivateKey* priv2;
test_key_rsa_keys_init(&keys, test);
+ priv_key = FOIL_KEY(keys.priv);
+
+ /* Invalid binary format produces NULL */
+ g_assert(!foil_key_to_binary_format(keys.pub, (FoilKeyBinaryFormat)-1));
+ g_assert(!foil_key_to_binary_format(priv_key, (FoilKeyBinaryFormat)-1));
+
+ /* No ssh-rsa format for RSA private key */
+ g_assert(!foil_key_to_binary_format(priv_key,
+ FOIL_KEY_BINARY_FORMAT_RSA_SSH));
+
+ /* Data in default format */
pub_data = foil_key_to_bytes(keys.pub);
- priv_data = foil_key_to_bytes(FOIL_KEY(keys.priv));
+ priv_data = foil_key_to_bytes(priv_key);
+
+ /* ssh-rsa format is the default public key format */
+ bytes = foil_key_to_binary_format(keys.pub,
+ FOIL_KEY_BINARY_FORMAT_RSA_SSH);
+ g_assert(g_bytes_equal(bytes, pub_data));
+ g_bytes_unref(bytes);
+
+ /* PKCS1 is the default RSA private key format */
+ bytes = foil_key_to_binary_format(priv_key,
+ FOIL_KEY_EXPORT_FORMAT_RSA_PKCS1);
+ g_assert(g_bytes_equal(bytes, priv_data));
+ g_bytes_unref(bytes);
+
+ /* Reconstruct the keys from the data in default format */
pub2 = foil_key_new_from_bytes(FOIL_KEY_RSA_PUBLIC, pub_data);
priv2 = foil_private_key_new_from_bytes(FOIL_KEY_RSA_PRIVATE, priv_data);
g_assert(pub2);
@@ -433,6 +460,17 @@
foil_key_unref(pub2);
foil_private_key_unref(priv2);
+
+ /* Test non-default PKCS #1 RSA public key format */
+ g_bytes_unref(pub_data);
+ pub_data = foil_key_to_binary_format(keys.pub,
+ FOIL_KEY_EXPORT_FORMAT_RSA_PKCS1);
+
+ pub2 = foil_key_new_from_bytes(FOIL_KEY_RSA_PUBLIC, pub_data);
+ g_assert(pub2);
+ g_assert(foil_key_equal(pub2, keys.pub));
+ foil_key_unref(pub2);
+
g_bytes_unref(pub_data);
g_bytes_unref(priv_data);
test_key_rsa_keys_deinit(&keys);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/test/libfoil/test_output/Makefile
^
|
@@ -1,5 +1,6 @@
# -*- Mode: makefile-gmake -*-
EXE = test_output
+COMMON_SRC = test_main.c test_hexdump.c
include ../../common/Makefile
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/foil/test/libfoil/test_output/test_output.c
^
|
@@ -1,26 +1,31 @@
/*
- * Copyright (C) 2016-2017 by Slava Monich
+ * Copyright (C) 2016-2022 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
@@ -30,16 +35,37 @@
#include "test_common.h"
#include "foil_output.h"
+#include "foil_cipher.h"
#include "foil_digest.h"
+#include "foil_hmac.h"
+#include "foil_key.h"
+#include "foil_private_key.h"
+
+#include <gutil_misc.h>
#include <glib/gstdio.h>
+#define TEST_(name) "/output/" name
+
+typedef struct test_output_cipher_data {
+ const char* name;
+ GUtilData key;
+ GType (*key_type)(void);
+ FoilKey* (*dec_key)(FoilKey*);
+ GType (*enc_type)(void);
+ GType (*dec_type)(void);
+ const void* input;
+ gsize input_size;
+} TestOutputCipher;
+
static
void
test_output_null(
void)
{
guint8 buf[1];
+ FoilKey* key = foil_key_generate_new(FOIL_TYPE_KEY_AES, 128);
+ FoilCipher* cipher = foil_cipher_new(FOIL_CIPHER_AES_CBC_ENCRYPT, key);
FoilOutput* out = foil_output_mem_new(NULL);
GBytes* empty = g_bytes_new_static(buf, 0);
@@ -48,6 +74,12 @@
foil_output_close(NULL);
foil_output_unref(NULL);
g_assert(!foil_output_ref(NULL));
+ g_assert(!foil_output_cipher_mem_new(NULL, NULL, NULL));
+ g_assert(!foil_output_cipher_mem_new2(NULL, NULL, NULL));
+ g_assert(!foil_output_cipher_new(NULL, cipher, NULL));
+ g_assert(!foil_output_cipher_new(NULL, NULL, NULL));
+ g_assert(!foil_output_cipher_new2(NULL, cipher, NULL));
+ g_assert(!foil_output_cipher_new2(NULL, NULL, NULL));
g_assert(!foil_output_digest_new(NULL, NULL));
g_assert(!foil_output_file_new_open(NULL));
g_assert(!foil_output_free_to_bytes(NULL));
@@ -58,6 +90,8 @@
g_assert(!foil_output_write(out, NULL, 0));
g_assert(!foil_output_write(out, buf, 0));
g_assert(!foil_output_write(out, NULL, 1));
+ g_assert(!foil_output_write_eol(NULL));
+ g_assert(!foil_output_write_byte(NULL, 1));
g_assert(foil_output_write_bytes(NULL, NULL) < 0);
g_assert(!foil_output_write_bytes(out, NULL));
g_assert(foil_output_write_bytes(out, empty) == 0);
@@ -65,6 +99,8 @@
g_assert(foil_output_write_bytes_all(out, NULL));
g_assert(foil_output_write_bytes_all(out, empty));
foil_output_unref(out);
+ foil_cipher_unref(cipher);
+ foil_key_unref(key);
g_bytes_unref(empty);
}
@@ -107,13 +143,259 @@
out = foil_output_mem_new(buf);
g_assert(foil_output_write_all(out, test123, sizeof(test123)));
g_byte_array_append(buf, test123, sizeof(test123));
- g_assert(!foil_output_free_to_bytes(out));
+ g_assert(!foil_output_free_to_bytes(out));
+
+ /* Writing a single byte */
+ g_byte_array_set_size(buf, 0);
+ out = foil_output_mem_new(buf);
+ g_assert(foil_output_write_byte(out, 42));
+ g_assert_cmpuint(buf->len, == ,1);
+ g_assert_cmpuint(buf->data[0], == ,42);
+ foil_output_unref(out);
g_byte_array_unref(buf);
}
static
void
+test_output_cipher_basic(
+ void)
+{
+ static const char prefix[] = "This is a prefix";
+ static const char test_data[] = "This is a secret";
+ GByteArray* buf1 = g_byte_array_new();
+ GByteArray* buf2 = g_byte_array_new();
+ FoilKey* key = foil_key_generate_new(FOIL_TYPE_KEY_AES, 128);
+ FoilCipher* cipher1 = foil_cipher_new(FOIL_CIPHER_AES_CBC_ENCRYPT, key);
+ FoilCipher* cipher2 = foil_cipher_new(FOIL_CIPHER_AES_CBC_ENCRYPT, key);
+ FoilOutput* buf = foil_output_mem_new(buf1);
+ FoilOutput* out = foil_output_cipher_new(buf, cipher1, NULL);
+ FoilOutput* out_mem;
+
+ /* Add some data in front of the ciphered data */
+ g_byte_array_append(buf2, (const void*)prefix, sizeof(prefix));
+ out_mem = foil_output_cipher_mem_new(buf2, cipher2, NULL);
+
+ foil_cipher_unref(cipher1);
+ foil_cipher_unref(cipher2);
+ g_assert(!foil_output_reset(out));
+ g_assert(!foil_output_reset(out_mem));
+ g_assert(foil_output_flush(out));
+ g_assert(foil_output_write_all(out, test_data, sizeof(test_data)));
+ g_assert(foil_output_write_all(out_mem, test_data, sizeof(test_data)));
+ TEST_DEBUG_HEXDUMP(buf1->data, buf1->len);
+ g_assert_cmpuint(buf1->len, > ,0);
+ g_assert_cmpuint(buf1->len, == ,buf2->len - sizeof(prefix));
+ g_assert(!memcmp(buf1->data, buf2->data + sizeof(prefix), buf1->len));
+ foil_output_unref(out_mem);
+
+ /* Fail to write to a closed stream */
+ foil_output_close(buf);
+ foil_output_unref(buf);
+ g_assert(!foil_output_write_all(out, test_data, sizeof(test_data)));
+ foil_output_unref(out);
+
+ /* Another kind of failure due to a closed underlying stream */
+ cipher1 = foil_cipher_new(FOIL_CIPHER_AES_CBC_ENCRYPT, key);
+ buf = foil_output_mem_new(NULL);
+ out = foil_output_cipher_new(buf, cipher1, NULL);
+ foil_cipher_unref(cipher1);
+
+ g_assert(foil_output_write_all(out, test_data, sizeof(test_data)));
+ foil_output_close(buf);
+ foil_output_unref(buf);
+ g_assert(!foil_output_free_to_bytes(out));
+
+ g_byte_array_unref(buf1);
+ g_byte_array_unref(buf2);
+ foil_key_unref(key);
+}
+
+static
+void
+test_output_cipher_digest(
+ gconstpointer param)
+{
+ static const char prefix[] = "This is a prefix";
+ const TestOutputCipher* test = param;
+ const guint8* in = test->input;
+ GType digest_type = FOIL_DIGEST_SHA1;
+ GByteArray* mem2 = g_byte_array_new_take(gutil_memdup(prefix,
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/harbour-lib/LICENSE
^
|
@@ -1,5 +1,5 @@
Copyright (C) 2015-2021 Jolla Ltd.
-Copyright (C) 2015-2021 Slava Monich <slava@monich.com>
+Copyright (C) 2015-2023 Slava Monich <slava@monich.com>
You may use this file under the terms of BSD license as follows:
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/harbour-lib/harbour-lib.pro
^
|
@@ -25,6 +25,7 @@
SOURCES += \
src/HarbourBase32.cpp \
src/HarbourBase45.cpp \
+ src/HarbourBattery.cpp \
src/HarbourClipboard.cpp \
src/HarbourColorEditorModel.cpp \
src/HarbourDisplayBlanking.cpp \
@@ -61,6 +62,7 @@
PUBLIC_HEADERS += \
include/HarbourBase32.h \
include/HarbourBase45.h \
+ include/HarbourBattery.h \
include/HarbourClipboard.h \
include/HarbourColorEditorModel.h \
include/HarbourDebug.h \
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/harbour-lib/include/HarbourBattery.h
^
|
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * 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 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.
+ */
+
+#ifndef HARBOUR_BATTERY_H
+#define HARBOUR_BATTERY_H
+
+#include <QObject>
+
+class QQmlEngine;
+class QJSEngine;
+
+// D-Bus calls used by this object require mce 1.86.0 (Sailfish OS 2.1)
+class HarbourBattery: public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(BatteryStatus batteryStatus READ batteryStatus NOTIFY batteryStatusChanged)
+ Q_PROPERTY(BatteryState batteryState READ batteryState NOTIFY batteryStateChanged)
+ Q_PROPERTY(int batteryLevel READ batteryLevel NOTIFY batteryLevelChanged)
+ Q_ENUMS(BatteryStatus)
+ Q_ENUMS(BatteryState)
+
+public:
+ enum BatteryStatus {
+ BatteryStatusUnknown,
+ BatteryStatusEmpty,
+ BatteryStatusLow,
+ BatteryStatusOk,
+ BatteryStatusFull
+ };
+
+ enum BatteryState {
+ BatteryStateUnknown,
+ BatteryStateCharging,
+ BatteryStateDischarging,
+ BatteryStateNotCharging,
+ BatteryStateFull
+ };
+
+ explicit HarbourBattery(QObject* aParent = Q_NULLPTR);
+ ~HarbourBattery();
+
+ // Callback for qmlRegisterSingletonType<HarbourBattery>
+ static QObject* createSingleton(QQmlEngine*, QJSEngine*);
+
+ BatteryStatus batteryStatus() const;
+ BatteryState batteryState() const;
+ int batteryLevel() const;
+
+Q_SIGNALS:
+ void batteryStatusChanged();
+ void batteryStateChanged();
+ void batteryLevelChanged();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+#endif // HARBOUR_BATTERY_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/harbour-lib/include/HarbourSelectionListModel.h
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2023 Slava Monich <slava@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -37,33 +37,44 @@
#include <QtQml>
#include <QIdentityProxyModel>
-class HarbourSelectionListModel : public QIdentityProxyModel {
+class HarbourSelectionListModel : public QIdentityProxyModel
+{
Q_OBJECT
Q_PROPERTY(QObject* sourceModel READ sourceModel WRITE setSourceModelObject NOTIFY sourceModelObjectChanged)
+ Q_PROPERTY(QList<int> nonSelectableRows READ nonSelectableRows WRITE setNonSelectableRows NOTIFY nonSelectableRowsChanged)
Q_PROPERTY(QList<int> selectedRows READ selectedRows NOTIFY selectedRowsChanged)
- Q_PROPERTY(int selectionCount READ selectionCount NOTIFY selectedRowsChanged)
+ Q_PROPERTY(int selectableCount READ selectableCount NOTIFY selectableCountChanged)
+ Q_PROPERTY(int selectionCount READ selectionCount NOTIFY selectionCountChanged)
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
public:
HarbourSelectionListModel(QObject* aParent = Q_NULLPTR);
- void setSourceModelObject(QObject* aModel);
+ void setSourceModelObject(QObject*);
+
+ QList<int> nonSelectableRows() const;
+ void setNonSelectableRows(const QList<int>);
QList<int> selectedRows() const;
+ int selectableCount() const;
int selectionCount() const;
Q_INVOKABLE void selectAll();
Q_INVOKABLE void clearSelection();
+ Q_INVOKABLE void toggleRows(const QList<int>);
// QAbstractItemModel
- Qt::ItemFlags flags(const QModelIndex& aIndex) const Q_DECL_OVERRIDE;
+ Qt::ItemFlags flags(const QModelIndex&) const Q_DECL_OVERRIDE;
QHash<int,QByteArray> roleNames() const Q_DECL_OVERRIDE;
- QVariant data(const QModelIndex& aIndex, int aRole) const Q_DECL_OVERRIDE;
- bool setData(const QModelIndex& aIndex, const QVariant& aValue, int aRole) Q_DECL_OVERRIDE;
+ QVariant data(const QModelIndex&, int) const Q_DECL_OVERRIDE;
+ bool setData(const QModelIndex&, const QVariant&, int) Q_DECL_OVERRIDE;
Q_SIGNALS:
void sourceModelObjectChanged();
+ void nonSelectableRowsChanged();
void selectedRowsChanged();
+ void selectableCountChanged();
+ void selectionCountChanged();
void countChanged();
private:
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/harbour-lib/qml/HarbourInvertEffect.qml
^
|
@@ -0,0 +1,13 @@
+import QtQuick 2.0
+
+ShaderEffect {
+ property variant source
+ fragmentShader: "
+ uniform sampler2D source;
+ uniform lowp float qt_Opacity;
+ varying highp vec2 qt_TexCoord0;
+ void main(void) {
+ highp vec4 pixelColor = texture2D(source, qt_TexCoord0);
+ gl_FragColor = vec4(vec3(1,1,1) - pixelColor.rgb, pixelColor.a) * qt_Opacity;
+ }"
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/harbour-lib/src/HarbourBattery.cpp
^
|
@@ -0,0 +1,266 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * 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 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.
+ */
+
+#include "HarbourBattery.h"
+#include "HarbourDebug.h"
+#include "HarbourMce.h"
+
+#include <QDBusPendingCallWatcher>
+#include <QDBusPendingReply>
+
+// ==========================================================================
+// HarbourBattery::Private
+// ==========================================================================
+
+class HarbourBattery::Private : public HarbourMce
+{
+ Q_OBJECT
+
+public:
+ static const QString MCE_BATTERY_STATUS_UNKNOWN;
+ static const QString MCE_BATTERY_STATUS_FULL;
+ static const QString MCE_BATTERY_STATUS_OK;
+ static const QString MCE_BATTERY_STATUS_LOW;
+ static const QString MCE_BATTERY_STATUS_EMPTY;
+
+ static const QString MCE_BATTERY_STATE_UNKNOWN;
+ static const QString MCE_BATTERY_STATE_DISCHARGING;
+ static const QString MCE_BATTERY_STATE_CHARGING;
+ static const QString MCE_BATTERY_STATE_NOT_CHARGING;
+ static const QString MCE_BATTERY_STATE_FULL;
+
+ Private(HarbourBattery*);
+
+ HarbourBattery* parentObject() const;
+
+public Q_SLOTS:
+ void updateBatteryStatus(const QString);
+ void updateBatteryState(const QString);
+ void updateBatteryLevel(int);
+ void onBatteryStatusQueryDone(QDBusPendingCallWatcher*);
+ void onBatteryStateQueryDone(QDBusPendingCallWatcher*);
+ void onBatteryLevelQueryDone(QDBusPendingCallWatcher*);
+
+public:
+ BatteryStatus iBatteryStatus;
+ BatteryState iBatteryState;
+ int iBatteryLevel;
+};
+
+const QString HarbourBattery::Private::MCE_BATTERY_STATUS_UNKNOWN("unknown");
+const QString HarbourBattery::Private::MCE_BATTERY_STATUS_FULL("full");
+const QString HarbourBattery::Private::MCE_BATTERY_STATUS_OK("ok");
+const QString HarbourBattery::Private::MCE_BATTERY_STATUS_LOW("low");
+const QString HarbourBattery::Private::MCE_BATTERY_STATUS_EMPTY("empty");
+
+const QString HarbourBattery::Private::MCE_BATTERY_STATE_UNKNOWN("unknown");
+const QString HarbourBattery::Private::MCE_BATTERY_STATE_DISCHARGING("discharging");
+const QString HarbourBattery::Private::MCE_BATTERY_STATE_CHARGING("charging");
+const QString HarbourBattery::Private::MCE_BATTERY_STATE_NOT_CHARGING("not_charging");
+const QString HarbourBattery::Private::MCE_BATTERY_STATE_FULL("full");
+
+HarbourBattery::Private::Private(
+ HarbourBattery* aParent) :
+ HarbourMce(aParent),
+ iBatteryStatus(BatteryStatusUnknown),
+ iBatteryState(BatteryStateUnknown),
+ iBatteryLevel(0)
+{
+ setupProperty("get_battery_status", "battery_status_ind",
+ SLOT(onBatteryStatusQueryDone(QDBusPendingCallWatcher*)),
+ SLOT(updateBatteryStatus(QString)));
+ setupProperty("get_battery_state", "battery_state_ind",
+ SLOT(onBatteryStateQueryDone(QDBusPendingCallWatcher*)),
+ SLOT(updateBatteryState(QString)));
+ setupProperty("get_battery_level", "battery_level_ind",
+ SLOT(onBatteryLevelQueryDone(QDBusPendingCallWatcher*)),
+ SLOT(updateBatteryLevel(int)));
+}
+
+inline
+HarbourBattery*
+HarbourBattery::Private::parentObject() const
+{
+ return qobject_cast<HarbourBattery*>(parent());
+}
+
+void
+HarbourBattery::Private::updateBatteryStatus(
+ const QString aStatus)
+{
+ BatteryStatus status = BatteryStatusUnknown;
+
+ if (aStatus == MCE_BATTERY_STATUS_OK) {
+ status = BatteryStatusOk;
+ } else if (aStatus == MCE_BATTERY_STATUS_FULL) {
+ status = BatteryStatusFull;
+ } else if (aStatus == MCE_BATTERY_STATUS_LOW) {
+ status = BatteryStatusLow;
+ } else if (aStatus == MCE_BATTERY_STATUS_EMPTY) {
+ status = BatteryStatusEmpty;
+ } else if (aStatus != MCE_BATTERY_STATUS_UNKNOWN) {
+ HWARN("Unexpected battery status" << aStatus);
+ return;
+ }
+
+ if (iBatteryStatus != status) {
+ iBatteryStatus = status;
+ HDEBUG(aStatus);
+ Q_EMIT parentObject()->batteryStatusChanged();
+ }
+}
+
+void
+HarbourBattery::Private::updateBatteryState(
+ const QString aState)
+{
+ BatteryState state = BatteryStateUnknown;
+
+ if (aState == MCE_BATTERY_STATE_CHARGING) {
+ state = BatteryStateCharging;
+ } else if (aState == MCE_BATTERY_STATE_DISCHARGING) {
+ state = BatteryStateDischarging;
+ } else if (aState == MCE_BATTERY_STATE_NOT_CHARGING) {
+ state = BatteryStateNotCharging;
+ } else if (aState == MCE_BATTERY_STATE_FULL) {
+ state = BatteryStateFull;
+ } else if (aState != MCE_BATTERY_STATE_UNKNOWN) {
+ HWARN("Unexpected battery state" << aState);
+ return;
+ }
+
+ if (iBatteryState != state) {
+ iBatteryState = state;
+ HDEBUG(aState);
+ Q_EMIT parentObject()->batteryStateChanged();
+ }
+}
+
+void
+HarbourBattery::Private::updateBatteryLevel(
+ int aLevel)
+{
+ if (iBatteryLevel != aLevel) {
+ iBatteryLevel = aLevel;
+ HDEBUG(aLevel);
+ Q_EMIT parentObject()->batteryLevelChanged();
+ }
+}
+
+void
+HarbourBattery::Private::onBatteryStatusQueryDone(
+ QDBusPendingCallWatcher* aWatcher)
+{
+ QDBusPendingReply<QString> reply(*aWatcher);
+
+ if (reply.isError()) {
+ HWARN(reply.error().message());
+ } else {
+ updateBatteryStatus(reply.value());
+ }
+ aWatcher->deleteLater();
+}
+
+void
+HarbourBattery::Private::onBatteryStateQueryDone(
+ QDBusPendingCallWatcher* aWatcher)
+{
+ QDBusPendingReply<QString> reply(*aWatcher);
+
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/harbour-lib/src/HarbourProtoBuf.cpp
^
|
@@ -41,21 +41,23 @@
QByteArray* aOutput,
quint64 aValue)
{
- uchar out[10];
- quint64 value = aValue;
- int i = sizeof(out) - 1;
-
- out[i] = value & 0x7f;
- value >>= 7;
- while (value) {
- out[--i] = 0x80 | (uchar)value;
+ if (aOutput) {
+ uchar out[10];
+ quint64 value = aValue;
+ int i = sizeof(out) - 1;
+
+ out[i] = value & 0x7f;
value >>= 7;
- }
+ while (value) {
+ out[--i] = 0x80 | (uchar)value;
+ value >>= 7;
+ }
- const int n = sizeof(out) - i;
+ const int n = sizeof(out) - i;
- aOutput->reserve(aOutput->size() + n);
- aOutput->append((char*)(out + i), n);
+ aOutput->reserve(aOutput->size() + n);
+ aOutput->append((char*)(out + i), n);
+ }
return aOutput;
}
@@ -74,7 +76,9 @@
QByteArray* aOutput,
const QByteArray aValue)
{
- appendVarInt(aOutput, aValue.size())->append(aValue);
+ if (aOutput) {
+ appendVarInt(aOutput, aValue.size())->append(aValue);
+ }
return aOutput;
}
@@ -93,20 +97,26 @@
GUtilRange* aPos,
quint64* aResult)
{
- quint64 value = 0;
- const guint8* ptr = aPos->ptr;
+ if (aPos) {
+ quint64 value = 0;
+ const guint8* ptr = aPos->ptr;
+
+ for (int i = 0; i < 10 && ptr < aPos->end; i++, ptr++) {
+ value = (value << 7) | (*ptr & 0x7f);
+ if (!(*ptr & 0x80)) {
+ aPos->ptr = ptr + 1;
+ if (aResult) {
+ *aResult = value;
+ }
+ return true;
+ }
+ }
- for (int i = 0; i < 10 && ptr < aPos->end; i++, ptr++) {
- value = (value << 7) | (*ptr & 0x7f);
- if (!(*ptr & 0x80)) {
- aPos->ptr = ptr + 1;
- *aResult = value;
- return true;
+ // Premature end of stream or too many bytes
+ if (aResult) {
+ *aResult = 0;
}
}
-
- // Premature end of stream or too many bytes
- *aResult = 0;
return false;
}
@@ -117,14 +127,18 @@
GUtilRange* aPos,
GUtilData* aPayload)
{
- GUtilRange pos = *aPos;
- quint64 size;
-
- if (parseVarInt(&pos, &size) && (pos.ptr + size) <= pos.end) {
- aPayload->bytes = pos.ptr;
- aPayload->size = size;
- aPos->ptr = pos.ptr + size;
- return true;
+ if (aPos) {
+ GUtilRange pos = *aPos;
+ quint64 size;
+
+ if (parseVarInt(&pos, &size) && (pos.ptr + size) <= pos.end) {
+ if (aPayload) {
+ aPayload->bytes = pos.ptr;
+ aPayload->size = size;
+ }
+ aPos->ptr = pos.ptr + size;
+ return true;
+ }
}
return false;
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/harbour-lib/src/HarbourSelectionListModel.cpp
^
|
@@ -1,6 +1,6 @@
-/*
+/*
* Copyright (C) 2019 Jolla Ltd.
- * Copyright (C) 2019 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2019-2023 Slava Monich <slava@jolla.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -41,20 +41,47 @@
// HarbourSelectionListModel::Private
// ==========================================================================
-class HarbourSelectionListModel::Private : public QObject {
+// s(SignalName,signalName)
+#define QUEUED_SIGNALS(s) \
+ s(NonSelectableRows,nonSelectableRows) \
+ s(SelectedRows,selectedRows) \
+ s(SelectableCount,selectableCount) \
+ s(SelectionCount,selectionCount) \
+ s(Count,count)
+
+class HarbourSelectionListModel::Private : public QObject
+{
Q_OBJECT
public:
- Private(HarbourSelectionListModel* aParent);
+ typedef void (HarbourSelectionListModel::*SignalEmitter)();
+ typedef uint SignalMask;
+
+ enum Signal {
+#define SIGNAL_ENUM_(Name,name) Signal##Name##Changed,
+ QUEUED_SIGNALS(SIGNAL_ENUM_)
+#undef SIGNAL_ENUM_
+ SignalCount
+ };
+
+ Private(HarbourSelectionListModel*);
+
+ static int binaryFind(const QList<int>, int);
HarbourSelectionListModel* parentModel();
- static int binaryFind(const QList<int> aList, int aValue);
- bool isSelectionRole(int aRole) const;
- bool isSelectedRow(int aRow) const;
- int findSelectedRow(int aRow) const;
- void selectRow(int aRow);
- void unselectRow(int aRow);
- void selectionChangedAt(int aRow);
+ void queueSignal(Signal aSignal);
+ void emitQueuedSignals();
+ bool isSelectionRole(int) const;
+ bool isSelectedRow(int) const;
+ bool isSelectableRow(int) const;
+ int findSelectedRow(int) const;
+ void updateCounts();
+ void selectRow(int);
+ void unselectRow(int);
+ void toggleRows(const QList<int>);
+ void setNonSelectableRows(const QList<int>);
+ void selectedRowChanged(int);
+ void selectionChangedAt(int);
void clearSelection();
void selectAll();
void reset();
@@ -63,13 +90,20 @@
void onCountChanged();
public:
+ SignalMask iQueuedSignals;
+ Signal iFirstQueuedSignal;
QList<int> iSelectedRows;
- QVector<int> iSelectedRole;
+ QList<int> iNonSelectableRows;
+ QList<int> iNormalizedNonSelectableRows;
+ QVector<int> iSelectedRole; // Passed to dataChanged as an argument
+ int iLastKnownSelectableCount;
int iLastKnownCount;
};
-HarbourSelectionListModel::Private::Private(HarbourSelectionListModel* aParent) :
+HarbourSelectionListModel::Private::Private(
+ HarbourSelectionListModel* aParent) :
QObject(aParent),
+ iLastKnownSelectableCount(0),
iLastKnownCount(0)
{
connect(aParent, SIGNAL(modelReset()), SLOT(onCountChanged()));
@@ -77,22 +111,10 @@
connect(aParent, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(onCountChanged()));
}
-inline HarbourSelectionListModel* HarbourSelectionListModel::Private::parentModel()
-{
- return qobject_cast<HarbourSelectionListModel*>(parent());
-}
-
-inline bool HarbourSelectionListModel::Private::isSelectionRole(int aRole) const
-{
- return !iSelectedRole.isEmpty() && iSelectedRole.first() == aRole;
-}
-
-inline bool HarbourSelectionListModel::Private::isSelectedRow(int aRow) const
-{
- return findSelectedRow(aRow) >= 0;
-}
-
-int HarbourSelectionListModel::Private::binaryFind(const QList<int> aList, int aValue)
+int
+HarbourSelectionListModel::Private::binaryFind(
+ const QList<int> aList,
+ int aValue)
{
// It turned out to be significantly easier to copy/paste this code
// than to fight with qBinaryFind and iterators which behave strangely
@@ -117,34 +139,131 @@
return -(low + 1);
}
-int HarbourSelectionListModel::Private::findSelectedRow(int aRow) const
+inline
+HarbourSelectionListModel*
+HarbourSelectionListModel::Private::parentModel()
+{
+ return qobject_cast<HarbourSelectionListModel*>(parent());
+}
+
+void
+HarbourSelectionListModel::Private::queueSignal(
+ Signal aSignal)
+{
+ if (aSignal >= 0 && aSignal < SignalCount) {
+ const SignalMask signalBit = (SignalMask(1) << aSignal);
+ if (iQueuedSignals) {
+ iQueuedSignals |= signalBit;
+ if (iFirstQueuedSignal > aSignal) {
+ iFirstQueuedSignal = aSignal;
+ }
+ } else {
+ iQueuedSignals = signalBit;
+ iFirstQueuedSignal = aSignal;
+ }
+ }
+}
+
+void
+HarbourSelectionListModel::Private::emitQueuedSignals()
+{
+ static const SignalEmitter emitSignal [] = {
+#define SIGNAL_EMITTER_(Name,name) &HarbourSelectionListModel::name##Changed,
+ QUEUED_SIGNALS(SIGNAL_EMITTER_)
+#undef SIGNAL_EMITTER_
+ };
+ if (iQueuedSignals) {
+ HarbourSelectionListModel* model = parentModel();
+ // Reset first queued signal before emitting the signals.
+ // Signal handlers may emit new signals.
+ uint i = iFirstQueuedSignal;
+ iFirstQueuedSignal = SignalCount;
+ for (; i < SignalCount && iQueuedSignals; i++) {
+ const SignalMask signalBit = (SignalMask(1) << i);
+ if (iQueuedSignals & signalBit) {
+ iQueuedSignals &= ~signalBit;
+ Q_EMIT (model->*(emitSignal[i]))();
+ }
+ }
+ }
+}
+
+inline
+bool
+HarbourSelectionListModel::Private::isSelectionRole(
+ int aRole) const
+{
+ return !iSelectedRole.isEmpty() && iSelectedRole.first() == aRole;
+}
+
+inline
+bool
+HarbourSelectionListModel::Private::isSelectedRow(
+ int aRow) const
+{
+ return findSelectedRow(aRow) >= 0;
+}
+
+inline
+bool
+HarbourSelectionListModel::Private::isSelectableRow(
+ int aRow) const
+{
+ return binaryFind(iNonSelectableRows, aRow) < 0;
+}
+
+int
+HarbourSelectionListModel::Private::findSelectedRow(
+ int aRow) const
{
return binaryFind(iSelectedRows, aRow);
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/harbour-lib/src/HarbourUtil.cpp
^
|
@@ -110,18 +110,7 @@
const void* aData,
size_t aSize)
{
- QByteArray hex;
-
- if (aSize > 0) {
- const uchar* bytes = (const uchar*)aData;
-
- hex.reserve(2 * aSize);
- for (size_t i = 0; i < aSize; i++) {
- const uchar b = bytes[i];
-
- hex.append(QChar(Private::hex[(b & 0xf0) >> 4]));
- hex.append(QChar(Private::hex[b & 0x0f]));
- }
- }
- return hex;
+ return aSize ?
+ QByteArray::fromRawData((const char*) aData, (int) aSize).toHex() :
+ QByteArray();
}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/harbour-lib/src/libcrypto.c
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2021 Jolla Ltd.
- * Copyright (C) 2021 Slava Monich <slava.monich@jolla.com>
+ * Copyright (C) 2021-2023 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of the BSD license as follows:
*
@@ -112,14 +112,22 @@
(const unsigned char* in, unsigned char* out, const AES_KEY* key, \
const int enc), \
(in, out, key, enc)) \
+ f(BN_clear_free, (BIGNUM *a), (a)) \
f(BN_free, (BIGNUM *a), (a)) \
f(DES_ede3_cbc_encrypt, \
(const unsigned char* input, unsigned char* output, long length, \
DES_key_schedule* ks1, DES_key_schedule* ks2, DES_key_schedule* ks3, \
DES_cblock* ivec, int enc), \
(input, output, length, ks1, ks2, ks3, ivec, enc)) \
- f(ERR_load_crypto_strings, (void), ()) \
- f(RSA_free, (RSA* r), (r))
+ f(/* libcrypto.so.10 */ ERR_load_crypto_strings, (void), ()) \
+ f(RSA_free, (RSA* r), (r)) \
+ f(/* libcrypto.so.1.1 */ RSA_get0_key, (const RSA* r, const BIGNUM** n, \
+ const BIGNUM** e, const BIGNUM** d), (r, n, e, d)) \
+ f(/* libcrypto.so.1.1 */ RSA_get0_factors, (const RSA* r, \
+ const BIGNUM** p, const BIGNUM** q), (r, p, q)) \
+ f(/* libcrypto.so.1.1 */ RSA_get0_crt_params, (const RSA* r, \
+ const BIGNUM** dmp1, const BIGNUM** dmq1, const BIGNUM** iqmp), \
+ (r, dmp1, dmq1, iqmp))
/* f(ret,name,params,args,def) */
#define LIBCRYPTO_FUNCTIONS2(f) \
@@ -149,7 +157,7 @@
f(int, MD5_Init, (MD5_CTX* c), (c), 0) \
f(int, MD5_Update, (MD5_CTX* c, const void* data, size_t len), \
(c, data, len), 0) \
- f(int, OPENSSL_init_crypto, \
+ f(int, /* libcrypto.so.1.1 */ OPENSSL_init_crypto, \
(uint64_t opts, const OPENSSL_INIT_SETTINGS* settings), \
(opts, settings), 0) \
f(int, RAND_bytes, (unsigned char* buf, int num), (buf, num), 0) \
@@ -173,6 +181,12 @@
(int flen, const unsigned char* from, unsigned char* to, RSA* rsa, \
int padding), (flen, from, to, rsa, padding), 0) \
f(int, RSA_size, (const RSA* rsa), (rsa), 0) \
+ f(int, /* libcrypto.so.1.1 */ RSA_set0_key, (RSA* r, BIGNUM* n, \
+ BIGNUM* e, BIGNUM* d), (r, n, e, d), 0) \
+ f(int, /* libcrypto.so.1.1 */ RSA_set0_factors, (RSA* r, BIGNUM* p, \
+ BIGNUM* q), (r, p, q), 0) \
+ f(int, /* libcrypto.so.1.1 */ RSA_set0_crt_params, (RSA* r, \
+ BIGNUM* dmp1, BIGNUM* dmq1, BIGNUM* iqmp), (r, dmp1, dmq1, iqmp), 0) \
f(unsigned char*, SHA1, (const unsigned char* d, size_t n, \
unsigned char* md), (d, n, md), NULL) \
f(int, SHA1_Final, (unsigned char* md, SHA_CTX* c), (md, c), 0) \
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/harbour-lib/test/Makefile
^
|
@@ -4,4 +4,5 @@
%:
@$(MAKE) -C TestHarbourBase32 $*
@$(MAKE) -C TestHarbourBase45 $*
+ @$(MAKE) -C TestHarbourProtoBuf $*
@$(MAKE) -C TestHarbourUtil $*
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/harbour-lib/test/TestHarbourProtoBuf/Makefile
^
|
@@ -0,0 +1,7 @@
+# -*- Mode: makefile-gmake -*-
+
+PKGS = libglibutil
+EXE = TestHarbourProtoBuf
+HARBOUR_SRC = HarbourProtoBuf.cpp
+
+include ../Makefile.common
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/harbour-lib/test/TestHarbourProtoBuf/TestHarbourProtoBuf.cpp
^
|
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2022 Jolla Ltd.
+ * Copyright (C) 2022 Slava Monich <slava.monich@jolla.com>
+ *
+ * You may use this file under the terms of the BSD license as follows:
+ *
+ * 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 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.
+ */
+
+#include "HarbourProtoBuf.h"
+
+#include <glib.h>
+
+/*==========================================================================*
+ * null
+ *==========================================================================*/
+
+static
+void
+test_null(
+ void)
+{
+ g_assert(!HarbourProtoBuf::appendVarInt(NULL, 0));
+ g_assert(!HarbourProtoBuf::appendVarIntKeyValue(NULL, 0, 0));
+ g_assert(!HarbourProtoBuf::appendDelimitedValue(NULL, QByteArray()));
+ g_assert(!HarbourProtoBuf::appendDelimitedKeyValue(NULL,
+ HarbourProtoBuf::TYPE_DELIMITED, QByteArray()));
+ g_assert(!HarbourProtoBuf::parseVarInt(NULL, NULL));
+ g_assert(!HarbourProtoBuf::parseDelimitedValue(NULL, NULL));
+}
+
+/*==========================================================================*
+ * int
+ *==========================================================================*/
+
+static
+void
+test_int(
+ void)
+{
+ QByteArray buf;
+ GUtilRange range;
+ quint64 res;
+
+ static const guint8 enc0[] = { 0 };
+
+ g_assert(HarbourProtoBuf::appendVarInt(&buf, 0) == &buf);
+ g_assert(buf == QByteArray::fromRawData((char*)enc0, sizeof(enc0)));
+
+ range.end = (range.ptr = enc0);
+ g_assert(!HarbourProtoBuf::parseVarInt(&range, NULL));
+ range.end = (range.ptr = enc0);
+
+ res = 42;
+ g_assert(!HarbourProtoBuf::parseVarInt(&range, &res));
+ g_assert_cmpuint(res, == ,0);
+
+ range.end = (range.ptr = enc0) + sizeof(enc0);
+ g_assert(HarbourProtoBuf::parseVarInt(&range, NULL));
+ g_assert(range.ptr == range.end);
+
+ res = 42;
+ range.end = (range.ptr = enc0) + sizeof(enc0);
+ g_assert(HarbourProtoBuf::parseVarInt(&range, &res));
+ g_assert_cmpuint(res, == ,0);
+
+ static const guint8 enc257[] = { 0x82, 0x01 };
+
+ buf.clear();
+ g_assert(HarbourProtoBuf::appendVarInt(&buf, 257) == &buf);
+ g_assert(buf == QByteArray::fromRawData((char*)enc257, sizeof(enc257)));
+
+ res = 42;
+ range.end = (range.ptr = enc257) + 1;
+ g_assert(!HarbourProtoBuf::parseVarInt(&range, &res));
+ g_assert_cmpuint(res, == ,0);
+
+ res = 42;
+ range.end = (range.ptr = enc257) + sizeof(enc257);
+ g_assert(HarbourProtoBuf::parseVarInt(&range, &res));
+ g_assert(range.ptr == range.end);
+ g_assert_cmpuint(res, == ,257);
+}
+
+/*==========================================================================*
+ * delimited
+ *==========================================================================*/
+
+static
+void
+test_delimited(
+ void)
+{
+ QByteArray buf;
+ GUtilRange range;
+ GUtilData payload;
+ static const guint8 value[] = { 0x01, 0x02 };
+ static const guint8 encodedValue[] = { 0x02, 0x01, 0x02 };
+
+ g_assert(HarbourProtoBuf::appendDelimitedValue(&buf,
+ QByteArray::fromRawData((char*)value, sizeof(value))) == &buf);
+ g_assert(buf == QByteArray::fromRawData((char*)encodedValue,
+ sizeof(encodedValue)));
+
+ range.end = (range.ptr = encodedValue);
+ g_assert(!HarbourProtoBuf::parseDelimitedValue(&range, NULL));
+ g_assert(range.ptr == encodedValue);
+
+ range.end = (range.ptr = encodedValue) + sizeof(encodedValue) - 1;
+ g_assert(!HarbourProtoBuf::parseDelimitedValue(&range, NULL));
+ g_assert(range.ptr == encodedValue);
+
+ range.end = (range.ptr = encodedValue) + sizeof(encodedValue);
+ g_assert(HarbourProtoBuf::parseDelimitedValue(&range, NULL));
+
+ memset(&payload, 0, sizeof(payload));
+ range.end = (range.ptr = encodedValue) + sizeof(encodedValue);
+ g_assert(HarbourProtoBuf::parseDelimitedValue(&range, &payload));
+ g_assert_cmpuint(payload.size, == ,sizeof(value));
+ g_assert(!memcmp(payload.bytes, value, sizeof(value)));
+}
+
+/*==========================================================================*
+ * Common
+ *==========================================================================*/
+
+#define TEST_(name) "/HarbourProtoBuf/" name
+
+int main(int argc, char* argv[])
+{
+ g_test_init(&argc, &argv, NULL);
+ g_test_add_func(TEST_("null"), test_null);
+ g_test_add_func(TEST_("int"), test_int);
+ g_test_add_func(TEST_("delimited"), test_delimited);
+ return g_test_run();
+}
+
+/*
+ * Local Variables:
+ * mode: C++
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/harbour-lib/test/TestHarbourUtil/TestHarbourUtil.cpp
^
|
@@ -80,15 +80,15 @@
0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14
};
- const QByteArray dataBytes(data, sizeof(data));
- const QByteArray hex(dataBytes.toHex());
+ // Lower case is assumed
+ const QByteArray hex("0102030405060708090a0b0c0d0e0f1011121314");
g_assert(HarbourUtil::toHex(QByteArray()).isEmpty());
g_assert(HarbourUtil::toHex(Q_NULLPTR, 0).isEmpty());
g_assert(HarbourUtil::toHexBytes(Q_NULLPTR, 0).isEmpty());
g_assert(HarbourUtil::toHex(data, sizeof(data)) == QString::fromLatin1(hex));
- g_assert_cmpstr(HarbourUtil::toHexBytes(data, sizeof(data)).constData(), == ,
- hex.constData());
+ const QByteArray out(HarbourUtil::toHexBytes(data, sizeof(data)));
+ g_assert_cmpstr(out.constData(), == ,hex.constData());
}
/*==========================================================================*
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/harbour-lib/test/coverage/run
^
|
@@ -6,6 +6,7 @@
TESTS="\
TestHarbourBase32 \
TestHarbourBase45 \
+TestHarbourProtoBuf \
TestHarbourUtil"
function err() {
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/qml/Buzz.qml
^
|
@@ -0,0 +1,5 @@
+import QtFeedback 5.0
+
+ThemeEffect {
+ effect: ThemeEffect.Press
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/qml/GroupListItem.qml
^
|
@@ -0,0 +1,62 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+import "harbour"
+
+Rectangle {
+ id: root
+ property string groupName
+ property bool selected
+ property bool highlighted
+ property bool editing
+ property alias editText: editor.text
+ color: "transparent"
+
+ signal doneEditing()
+
+ function startEditing() {
+ editor.forceActiveFocus()
+ }
+
+ Rectangle {
+ anchors.fill: parent
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: Theme.rgba(Theme.highlightBackgroundColor, 0.15) }
+ GradientStop { position: 1.0; color: "transparent" }
+ }
+ }
+
+ Label {
+ visible: !editing
+ anchors {
+ left: parent.left
+ right: parent.right
+ rightMargin: Theme.horizontalPageMargin
+ leftMargin: Theme.horizontalPageMargin
+ verticalCenter: parent.verticalCenter
+ }
+ truncationMode: TruncationMode.Fade
+ text: groupName
+ color: selected ? Theme.highlightColor : (highlighted ? Theme.highlightColor : Theme.primaryColor)
+ }
+
+ TextField {
+ id: editor
+ y: Theme.paddingSmall
+ visible: editing
+ anchors {
+ left: parent.left
+ right: parent.right
+ rightMargin: Theme.horizontalPageMargin
+ leftMargin: Theme.horizontalPageMargin
+ verticalCenter: parent.verticalCenter
+ }
+ textLeftMargin: 0
+ textRightMargin: 0
+ horizontalAlignment: Text.AlignLeft
+ labelVisible: false
+ onActiveFocusChanged: if (!activeFocus) root.doneEditing()
+ EnterKey.onClicked: root.focus = true
+ EnterKey.iconSource: "image://theme/icon-m-enter-close"
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/qml/OrganizeGroupsView.qml
^
|
@@ -0,0 +1,132 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+import harbour.foilauth 1.0
+
+Item {
+ id: thisView
+
+ property alias foilModel: groupModel.sourceModel
+
+ PageHeader {
+ id: header
+
+ //: Page header title
+ //% "Manage groups"
+ title: qsTrId("foilauth-organize-groups-title")
+ //: Page header descriptions
+ //% "Create, delete and rename groups"
+ description: qsTrId("foilauth-organize-groups-description")
+ }
+
+ SilicaListView {
+ id: list
+
+ property var _editItem
+
+ clip: true
+ width: parent.width
+ anchors {
+ top: header.bottom
+ bottom: parent.bottom
+ }
+
+ model: FoilAuthGroupModel {
+ id: groupModel
+ }
+
+ delegate: ListItem {
+ id: listItem
+
+ readonly property string modelId: model.modelId
+
+ width: parent.width
+
+ menu: Component {
+ ContextMenu {
+ MenuItem {
+ //: Context menu item
+ //% "Rename"
+ text: qsTrId("foilauth-organize-groups-menu-rename")
+ onClicked: listItem.startEditing()
+ }
+ MenuItem {
+ //: Context menu item
+ //% "Delete"
+ text: qsTrId("foilauth-organize-groups-menu-delete")
+ onClicked: listItem.remove()
+ }
+ }
+ }
+
+ function remove() {
+ //: Remorse item label
+ //% "Deleting"
+ remorseAction(qsTrId("foilauth-organize-groups-remorse-deleting"), function() {
+ foilModel.deleteGroupItem(listItem.modelId)
+ })
+ }
+
+ function startEditing() {
+ groupItem.editText = model.label
+ list._editItem = listItem
+ groupItem.startEditing()
+ }
+
+ GroupListItem {
+ id: groupItem
+
+ width: listItem.width
+ height: listItem.contentHeight
+ groupName: model.label
+ highlighted: listItem.highlighted
+ editing: list._editItem === listItem
+
+ onDoneEditing: {
+ list._editItem = null
+ if (editText.length > 0) {
+ model.label = editText
+ }
+ }
+ }
+
+ ListView.onAdd: AddAnimation { target: listItem }
+ ListView.onRemove: RemoveAnimation { target: listItem }
+ }
+
+ footer: BackgroundItem {
+ id: addGroupItem
+
+ Image {
+ id: addIcon
+
+ x: Theme.horizontalPageMargin - Theme.paddingSmall
+ anchors.verticalCenter: parent.verticalCenter
+ source: "image://theme/icon-m-add" + (addGroupItem.highlighted ? "?" + Theme.highlightColor : "")
+ }
+
+ Label {
+ //: List footer button label
+ //% "Add group"
+ text: qsTrId("foilauth-organize-groups-add_group")
+ anchors {
+ left: addIcon.right
+ leftMargin: Theme.paddingSmall
+ verticalCenter: parent.verticalCenter
+ right: parent.right
+ rightMargin: Theme.horizontalPageMargin
+ }
+ color: addGroupItem.highlighted ? Theme.highlightColor : Theme.primaryColor
+ }
+
+ onClicked: {
+ //: Default name for the new group
+ //% "New group"
+ foilModel.addGroup(qsTrId("foilauth-organize-groups-new_group"))
+ list.currentIndex = groupModel.count - 1
+ list.currentItem.startEditing()
+ }
+ }
+
+ VerticalScrollDecorator { }
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/qml/OrganizePage.qml
^
|
@@ -0,0 +1,99 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+Page {
+ id: thisPage
+
+ property var foilModel
+
+ readonly property int _fullHeight: thisPage.isPortrait ? Screen.height : Screen.width
+
+ MouseArea {
+ height: thisPage.isLandscape ? Theme.itemSizeSmall : Theme.itemSizeLarge
+ width: parent.width
+ z: scroller.z + 1
+ }
+
+ SilicaListView {
+ id: scroller
+
+ width: parent.width
+ height: Math.min(toolPanel.y, thisPage.height)
+ orientation: ListView.Horizontal
+ snapMode: ListView.SnapOneItem
+ highlightRangeMode: ListView.StrictlyEnforceRange
+ flickDeceleration: maximumFlickVelocity
+ interactive: !scrollAnimation.running
+ clip: true
+
+ readonly property real maxContentX: originX + Math.max(0, contentWidth - width)
+
+ model: [ reorderViewComponent, groupsViewComponent ]
+ delegate: Loader {
+ width: scroller.width
+ height: scroller.height
+ sourceComponent: modelData
+ }
+ }
+
+ Component {
+ id: reorderViewComponent
+
+ OrganizeReorderView {
+ anchors.fill: parent
+ foilModel: thisPage.foilModel
+ isLandscape: thisPage.isLandscape
+ }
+ }
+
+ Component {
+ id: groupsViewComponent
+
+ OrganizeGroupsView {
+ anchors.fill: parent
+ // FoilAuthGroupModel slows down reordering, use it only when needed
+ foilModel: (scroller.contentX > scroller.originX) ? thisPage.foilModel : null
+ }
+ }
+
+ OrganizeToolPanel {
+ id: toolPanel
+
+ // Position this panel at the bottom of the screen so that it gets
+ // hidden behind the keyboard
+ y: _fullHeight - height
+ highlightReorderButton: scroller.currentIndex === 0
+ highlightGroupButtom: scroller.currentIndex === 1
+ onReorderTokens: { // Animate positionViewAtBeginning()
+ if (!scrollAnimation.running && scroller.contentX > scroller.originX) {
+ scrollAnimation.from = scroller.contentX
+ scrollAnimation.to = scroller.originX
+ scrollAnimation.start()
+ }
+ }
+ onGroupTokens: { // Animate positionViewAtEnd()
+ if (!scrollAnimation.running && scroller.contentX < scroller.maxContentX) {
+ scrollAnimation.from = scroller.contentX
+ scrollAnimation.to = scroller.maxContentX
+ scrollAnimation.start()
+ }
+ }
+ }
+
+ Rectangle {
+ x: (scroller.contentX - scroller.originX)/2
+ y: toolPanel.y
+ width: toolPanel.width/2
+ height: toolPanel.height
+ color: Theme.rgba(Theme.highlightBackgroundColor, 0.1)
+ }
+
+ NumberAnimation {
+ id: scrollAnimation
+
+ target: scroller
+ property: "contentX"
+ duration: 200
+ easing.type: Easing.InOutQuad
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/qml/OrganizeReorderView.qml
^
|
@@ -0,0 +1,224 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+import harbour.foilauth 1.0
+
+Item {
+ id: thisView
+
+ property var foilModel
+ property bool isLandscape
+
+ PageHeader {
+ id: header
+
+ //: Page header title
+ //% "Organize tokens"
+ title: qsTrId("foilauth-organize-tokens-title")
+ //: Page header descriptions
+ //% "Press, hold and drag to reorder"
+ description: qsTrId("foilauth-organize-tokens-description")
+ }
+
+ SilicaListView {
+ id: list
+
+ property var _dragItem
+ readonly property real _dragEdge: Theme.horizontalPageMargin
+ readonly property real _maxContentY: Math.max(originY + contentHeight - height, originY)
+
+ clip: true
+ width: parent.width
+ anchors {
+ top: header.bottom
+ bottom: parent.bottom
+ }
+
+ interactive: !Drag.active
+ currentIndex: listModel.dragPos
+ model: HarbourOrganizeListModel {
+ id: listModel
+
+ sourceModel: foilModel
+ }
+
+ moveDisplaced: Transition {
+ NumberAnimation {
+ properties: "x,y"
+ duration: 50
+ easing.type: Easing.InOutQuad
+ }
+ }
+
+ delegate: ListItem {
+ id: listItem
+
+ readonly property bool dragging: list._dragItem === listItem
+ readonly property bool _hidden: !model.groupHeader && model.hidden
+ readonly property int _modelIndex: index
+
+ height: _hidden ? 0 : implicitHeight
+ visible: height > 0
+
+ Behavior on height { SmoothedAnimation { duration: 200 } }
+
+ Item {
+ id: draggableItem
+
+ width: listItem.width
+ height: listItem.contentHeight
+ clip: height < listItem.contentHeight
+ scale: listItem.dragging ? 1.05 : 1
+
+ Loader {
+ active: !model.groupHeader
+ anchors.fill: parent
+ sourceComponent: Component {
+ TokenListItem {
+ description: model.label
+ prevPassword: model.prevPassword
+ currentPassword: model.currentPassword
+ nextPassword: model.nextPassword
+ favorite: model.favorite
+ interactive: false
+ hotp: model.type === FoilAuth.TypeHOTP
+ hotpMinus: model.counter > 0
+ landscape: thisView.isLandscape
+ color: listItem.dragging ? Theme.rgba(Theme.highlightBackgroundColor, 0.2) : "transparent"
+ selected: listItem.down
+ enabled: listItem.enabled
+ opacity: listItem._hidden ? 0 : enabled ? 1 : 0.2
+
+ onFavoriteToggled: model.favorite = !model.favorite
+ onIncrementCounter: {
+ model.counter++
+ copyPassword()
+ buzz()
+ }
+ onDecrementCounter: {
+ model.counter--
+ copyPassword()
+ buzz()
+ }
+
+ Behavior on color { ColorAnimation { duration: 150 } }
+ Behavior on opacity { FadeAnimation { duration: 200 } }
+ }
+ }
+ }
+
+ Loader {
+ active: model.groupHeader
+ anchors.fill: parent
+ sourceComponent: Component {
+ GroupHeader {
+ title: model.label
+ expanded: !model.hidden
+ }
+ }
+ }
+
+ Connections {
+ target: listItem.dragging ? list : null
+ onContentYChanged: draggableItem.handleScrolling()
+ }
+
+ onYChanged: handleScrolling()
+
+ function handleScrolling() {
+ if (listItem.dragging) {
+ var i = list.indexAt(list.width/2, y + list.contentY + height/2)
+ if (i >= 0 && i !== listItem._modelIndex) {
+ // Swap the items
+ list.model.dragPos = i
+ }
+ var bottom = y + height * 3 / 2
+ if (bottom > list.height) {
+ // Scroll the list down
+ scrollAnimation.stop()
+ scrollAnimation.from = list.contentY
+ scrollAnimation.to = Math.min(list._maxContentY, list.contentY + bottom + height - list.height)
+ if (scrollAnimation.to > scrollAnimation.from) {
+ scrollAnimation.start()
+ }
+ } else {
+ var top = y - height / 2
+ if (top < 0) {
+ // Scroll the list up
+ scrollAnimation.stop()
+ scrollAnimation.from = list.contentY
+ scrollAnimation.to = Math.max(list.originY, list.contentY + top - height)
+ if (scrollAnimation.to < scrollAnimation.from) {
+ scrollAnimation.start()
+ }
+ }
+ }
+ }
+ }
+
+ states: [
+ State {
+ name: "dragging"
+ when: listItem.dragging
+ ParentChange {
+ target: draggableItem
+ parent: list
+ y: draggableItem.mapToItem(list, 0, 0).y
+ }
+ },
+ State {
+ name: "normal"
+ when: !listItem.dragging
+ ParentChange {
+ target: draggableItem
+ parent: listItem.contentItem
+ y: 0
+ }
+ }
+ ]
+
+ Behavior on scale {
+ NumberAnimation {
+ duration: 150
+ easing.type: Easing.InOutQuad
+ }
+ }
+ }
+
+ onClicked: {
+ if (model.groupHeader) {
+ model.hidden = !model.hidden
+ }
+ }
+
+ onPressAndHold: list._dragItem = listItem
+ onReleased: stopDrag()
+ onCanceled: stopDrag()
+ onDraggingChanged: {
+ if (dragging) {
+ listModel.dragIndex = index
+ }
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/qml/OrganizeToolPanel.qml
^
|
@@ -0,0 +1,63 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+
+import "harbour"
+
+Rectangle {
+ id: thisItem
+
+ property bool active
+ property bool highlightReorderButton
+ property bool highlightGroupButtom
+
+ signal reorderTokens()
+ signal groupTokens()
+
+ height: Math.max(reorderButton.height, groupButton.height) + 2 * Theme.paddingMedium
+ color: Theme.rgba(Theme.highlightBackgroundColor, 0.1)
+ anchors {
+ left: parent.left
+ right: parent.right
+ }
+
+ MouseArea {
+ id: reorderButtonArea
+
+ width: thisItem.width/2
+ height: parent.height
+
+ property bool down: pressed && containsMouse
+
+ HarbourIconTextButton {
+ id: reorderButton
+
+ anchors.centerIn: parent
+ highlighted: down || reorderButtonArea.down || highlightReorderButton
+ iconSource: "image://theme/icon-m-transfer"
+ onClicked: thisItem.reorderTokens()
+ }
+
+ onClicked: thisItem.reorderTokens()
+ }
+
+ MouseArea {
+ id: groupButtonArea
+
+ x: width
+ width: thisItem.width/2
+ height: parent.height
+
+ property bool down: pressed && containsMouse
+
+ HarbourIconTextButton {
+ id: groupButton
+
+ anchors.centerIn: parent
+ highlighted: down || groupButtonArea.down || highlightGroupButtom
+ iconSource: Qt.resolvedUrl("images/folder.svg")
+ onClicked: thisItem.groupTokens()
+ }
+
+ onClicked: thisItem.groupTokens()
+ }
+}
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/qml/SelectPage.qml
^
|
@@ -5,7 +5,7 @@
Page {
id: thisPage
- property alias sourceModel: selectionModel.sourceModel
+ property var foilModel
property Item toolPanel
signal deleteRows(var rows)
@@ -36,7 +36,7 @@
function updateMenuItems() {
if (!active) {
selectNoneMenuItem.visible = selectionModel.selectionCount > 0
- selectAllMenuItem.visible = selectionModel.selectionCount < selectionModel.count
+ selectAllMenuItem.visible = selectionModel.selectionCount < selectionModel.selectableCount
}
}
MenuItem {
@@ -61,8 +61,10 @@
model: HarbourSelectionListModel {
id: selectionModel
+ sourceModel: foilModel
+ nonSelectableRows: foilModel.groupHeaderRows
onSelectionCountChanged: pullDownMenu.updateMenuItems()
- onCountChanged: pullDownMenu.updateMenuItems()
+ onSelectableCountChanged: pullDownMenu.updateMenuItems()
}
header: PageHeader {
@@ -72,21 +74,50 @@
}
delegate: ListItem {
- TokenListItem {
- anchors.fill: parent
- interactive: false
- description: model.label
- prevPassword: model.prevPassword
- currentPassword: model.currentPassword
- nextPassword: model.nextPassword
- favorite: model.favorite
- hotp: model.type === FoilAuth.TypeHOTP
- hotpMinus: model.counter > 0
- landscape: thisPage.isLandscape
- color: model.selected ? Theme.rgba(Theme.highlightBackgroundColor, 0.2) : "transparent"
- selected: model.selected
+ id: listItem
+
+ Loader {
+ active: !model.groupHeader
+ width: listItem.width
+ height: listItem.contentHeight
+ sourceComponent: Component {
+ TokenListItem {
+ anchors.fill: parent
+ interactive: false
+ description: model.label
+ prevPassword: model.prevPassword
+ currentPassword: model.currentPassword
+ nextPassword: model.nextPassword
+ favorite: model.favorite
+ hotp: model.type === FoilAuth.TypeHOTP
+ hotpMinus: model.counter > 0
+ landscape: thisPage.isLandscape
+ color: model.selected ? Theme.rgba(Theme.highlightBackgroundColor, 0.2) : "transparent"
+ selected: model.selected
+ }
+ }
+ }
+
+ Loader {
+ active: model.groupHeader
+ width: listItem.width
+ height: listItem.contentHeight
+ sourceComponent: Component {
+ GroupHeader {
+ title: model.label
+ }
+ }
+ }
+
+ onClicked: {
+ if (model.groupHeader) {
+ var rows = foilModel.itemRowsForGroupAt(index)
+ console.log(index,"=>",rows)
+ selectionModel.toggleRows(rows)
+ } else {
+ model.selected = !model.selected
+ }
}
- onClicked: model.selected = !model.selected
}
VerticalScrollDecorator { }
@@ -106,7 +137,7 @@
SelectToolPanel {
id: toolPanel
- readonly property var exportList: sourceModel.generateMigrationUris(selectionModel.selectedRows)
+ readonly property var exportList: foilModel.generateMigrationUris(selectionModel.selectedRows)
active: selectionModel.selectionCount > 0
canExport: exportList.length > 0
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/qml/SelectToolPanel.qml
^
|
@@ -6,14 +6,9 @@
Item {
id: thisPanel
- height: Math.max(deleteButton.height, exportButton.height) + 2 * Theme.paddingMedium
- y: parent.height - visiblePart
- visible: visiblePart > 0
-
property bool active
property bool canDelete: active
property bool canExport: active
- property real visiblePart: active ? height : 0
signal exportSelectedItems()
signal deleteSelectedItems()
@@ -21,13 +16,18 @@
signal showExportHint()
signal hideHint()
- Behavior on visiblePart { SmoothedAnimation { duration: 250 } }
-
+ height: Math.max(deleteButton.height, exportButton.height) + 2 * Theme.paddingMedium
+ y: parent.height - _visiblePart
+ visible: _visiblePart > 0
anchors {
left: parent.left
right: parent.right
}
+ property real _visiblePart: active ? height : 0
+
+ Behavior on _visiblePart { SmoothedAnimation { duration: 250 } }
+
HarbourIconTextButton {
id: deleteButton
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/qml/TokenListView.qml
^
|
@@ -6,498 +6,411 @@
import "foil-ui"
import "harbour"
-SilicaListView {
- id: tokenList
+Item {
+ id: thisItem
property Page mainPage
property var foilUi
property var foilModel
- property var dragItem
property var disabledItems: []
- readonly property bool isLandscape: mainPage && mainPage.isLandscape
- readonly property real dragEdge: Theme.horizontalPageMargin
- readonly property real dragThresholdX: Theme.itemSizeSmall/2
- readonly property real dragThresholdY: Theme.itemSizeSmall/5
- readonly property real maxContentY: Math.max(originY + contentHeight - height, originY)
-
- anchors.fill: parent
- interactive: !scrollAnimation.running
- currentIndex: listModel.dragPos
+ readonly property bool _isLandscape: mainPage && mainPage.isLandscape
- model: HarbourOrganizeListModel {
- id: listModel
+ SilicaListView {
+ id: tokenList
- sourceModel: foilModel
- }
+ anchors.fill: parent
- Notification {
- id: clipboardNotification
+ model: HarbourOrganizeListModel {
+ id: listModel
- //: Pop-up notification
- //% "Password copied to clipboard"
- previewBody: qsTrId("foilauth-notification-copied_to_clipboard")
- expireTimeout: 2000
- Component.onCompleted: {
- if ("icon" in clipboardNotification) {
- clipboardNotification.icon = "icon-s-clipboard"
- }
+ sourceModel: foilModel
}
- }
- Component.onCompleted: {
- SailOTP.importedTokens = FoilAuthSettings.sailotpImportedTokens
- var n = SailOTP.fetchNewTokens(FoilAuthModel)
- if (n > 0) {
- var dialog = pageStack.push(Qt.resolvedUrl("ImportTokensDialog.qml"), {
- allowedOrientations: mainPage.allowedOrientations,
- firstTime: !FoilAuthSettings.sailotpImportDone,
- count: n
- })
- if (dialog) {
- dialog.accepted.connect(function() {
- FoilAuthSettings.sailotpImportDone = true
- FoilAuthSettings.sailotpImportedTokens = SailOTP.importedTokens
- SailOTP.importTokens(FoilAuthModel)
- })
- dialog.rejected.connect(function() {
- FoilAuthSettings.sailotpImportDone = true
- FoilAuthSettings.sailotpImportedTokens = SailOTP.importedTokens
- SailOTP.dropTokens()
- })
- }
- }
- }
+ Loader {
+ id: buzzLoader
- Component {
- id: remorsePopupComponent
+ active: false
+ source: Qt.resolvedUrl("Buzz.qml")
+ }
- RemorsePopup { }
- }
+ function buzz() {
+ // Load buzzer on demand
+ buzzLoader.active = true
+ if (buzzLoader.item) {
+ buzzLoader.item.play()
+ }
+ }
- Component {
- id: editAuthTokenDialogComponent
+ Notification {
+ id: clipboardNotification
- EditAuthTokenDialog {
- allowedOrientations: mainPage.allowedOrientations
+ //: Pop-up notification
+ //% "Password copied to clipboard"
+ previewBody: qsTrId("foilauth-notification-copied_to_clipboard")
+ expireTimeout: 2000
+ Component.onCompleted: {
+ if ("icon" in clipboardNotification) {
+ clipboardNotification.icon = "icon-s-clipboard"
+ }
+ }
}
- }
- PullDownMenu {
- MenuItem {
- //: Pulley menu item, changes Foil password
- //% "Change password"
- text: qsTrId("foilauth-menu-change_foil_password")
- onClicked: pageStack.push(Qt.resolvedUrl("foil-ui/FoilUiChangePasswordPage.qml"), {
- mainPage: tokenList.mainPage,
- foilUi: tokenList.foilUi,
- foilModel: tokenList.foilModel,
- //: Password change prompt
- //% "Please enter the current and the new password"
- promptText: qsTrId("foilauth-change_password_page-label-enter_passwords"),
- //: Placeholder and label for the current password prompt
- //% "Current password"
- currentPasswordLabel: qsTrId("foilauth-change_password_page-text_field_label-current_password"),
- //: Placeholder and label for the new password prompt
- //% "New password"
- newPasswordLabel: qsTrId("foilauth-change_password_page-text_field_label-new_password"),
- //: Button label
- //% "Change password"
- buttonText: qsTrId("foilauth-change_password_page-button-change_password")
- })
- }
- MenuItem {
- //: Pulley menu item, locks the tokens
- //% "Lock"
- text: qsTrId("foilauth-menu-lock")
- onClicked: foilModel.lock(false)
- }
- MenuItem {
- //: Pulley menu item, opens selection page
- //% "Select"
- text: qsTrId("foilauth-menu-select_tokens")
- visible: foilModel.count > 0
- onClicked: {
- disabledItems = []
- var selectPage = pageStack.push(Qt.resolvedUrl("SelectPage.qml"), {
+ Component.onCompleted: {
+ SailOTP.importedTokens = FoilAuthSettings.sailotpImportedTokens
+ var n = SailOTP.fetchNewTokens(FoilAuthModel)
+ if (n > 0) {
+ var dialog = pageStack.push(Qt.resolvedUrl("ImportTokensDialog.qml"), {
allowedOrientations: mainPage.allowedOrientations,
- sourceModel: mainPage.foilModel
- })
- selectPage.deleteRows.connect(function(rows) {
- disabledItems = foilModel.getIdsAt(rows)
- pageStack.pop()
- if (disabledItems.length > 0) {
- var remorsePopup = remorsePopupComponent.createObject(mainPage)
- remorsePopup.canceled.connect(function() {
- disabledItems = []
- remorsePopup.destroy()
- })
- remorsePopup.triggered.connect(function() {
- // disabledItems will be updated when the remove animation
- // gets completed so that the item keeps looking disabled
- // during removal
- foilModel.deleteTokens(disabledItems)
- remorsePopup.destroy()
- })
- remorsePopup.execute((disabledItems.length === 1) ?
- //: Remorse popup text (single token selected)
- //% "Deleting selected token"
- qsTrId("foilauth-remorse-deleting_selected_token") :
- //: Remorse popup text (multiple tokens selected)
- //% "Deleting selected tokens"
- qsTrId("foilauth-remorse-deleting_selected_tokens"))
- }
- })
- }
- }
- MenuItem {
- //: Pulley menu item, creates a new authentication token
- //% "Add token"
- text: qsTrId("foilauth-menu-new_auth_token")
- onClicked: {
- var page = pageStack.push("ScanPage.qml", {
- "allowedOrientations": allowedOrientations
+ firstTime: !FoilAuthSettings.sailotpImportDone,
+ count: n
})
-
- page.skip.connect(function() {
- pageStack.replace(editAuthTokenDialogComponent, {
- //% "Add token"
- "dialogTitle": qsTrId("foilauth-add_token-title")
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/qml/images/folder.svg
^
|
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<svg
+ version="1.1"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ x="0px"
+ y="0px"
+ viewBox="0 0 64 64"
+ style="enable-background:new 0 0 64 64"
+ xml:space="preserve">
+ <g style="fill:#ffffff">
+ <rect
+ style="opacity:0"
+ width="64"
+ height="64"/>
+ <g style="opacity:0.6">
+ <path d="M29.7,16l-2.59-2.065C26.273,12.74,24.699,12,22.993,12H12.357C11.161,12,10,13.214,10,14.5V20 h13.091c1.646,0,3.164-0.713,3.971-1.866L29.7,16z"/>
+ <path d="M23.091,21H9v-6.5c0-1.832,1.6-3.5,3.357-3.5h10.636c1.967,0,3.809,0.854,4.848,2.238l3.457,2.756 l-3.503,2.835C26.785,20.171,24.999,21,23.091,21z M11,19h12.091c1.322,0,2.53-0.552,3.152-1.439l0.19-0.204l1.67-1.351 l-1.812-1.497C25.64,13.578,24.375,13,22.993,13H12.357C11.765,13,11,13.728,11,14.5V19z"/>
+ </g>
+ <path d="M51.75,53h-39.5C10.458,53,9,51.542,9,49.75V20.875C9,19.841,9.841,19,10.875,19h8.64 c2.131,0,5.274-0.441,5.796-0.74c0.602-0.486,1.717-1.385,2.441-1.971c1.035-0.837,3.618-1.29,5.524-1.29h18.516 C53.561,15,55,16.439,55,18.208V49.75C55,51.542,53.542,53,51.75,53z M11,21v28.75c0,0.689,0.561,1.25,1.25,1.25h39.5 c0.689,0,1.25-0.561,1.25-1.25V18.208C53,17.542,52.458,17,51.792,17H33.276c-1.967,0-3.841,0.5-4.266,0.844 c-0.727,0.588-1.845,1.489-2.485,2.002C25.433,20.724,20.744,21,19.515,21H11z"/>
+ </g>
+</svg>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/settings/settings.qml
^
|
@@ -26,7 +26,7 @@
description: applicationName ?
//: Settings page header description (app version)
//% "Version %1"
- qsTrId("foilauth-settings_page-header-version").arg("1.1.4") : ""
+ qsTrId("foilauth-settings_page-header-version").arg("1.1.5") : ""
Image {
id: appIcon
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/src/FoilAuth.cpp
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2019-2022 Jolla Ltd.
- * Copyright (C) 2019-2022 Slava Monich <slava@monich.com>
+ * Copyright (C) 2019-2023 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -219,6 +219,17 @@
return aList;
}
+const char*
+FoilAuth::generateId(
+ GString* aString)
+{
+ guint8 data[8];
+ foil_random_generate(FOIL_RANDOM_DEFAULT, data, sizeof(data));
+ g_string_append_printf(aString, "%02X%02X%02X%02X%02X%02X%02X%02X",
+ data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7]);
+ return aString->str;
+}
+
FoilOutput*
FoilAuth::createFoilFile(
const QString aDestDir,
@@ -233,12 +244,8 @@
g_string_append_c(aOutPath, '/');
const gsize prefix_len = aOutPath->len;
for (int i = 0; i < 100 && !out; i++) {
- guint8 data[8];
- foil_random_generate(FOIL_RANDOM_DEFAULT, data, sizeof(data));
g_string_truncate(aOutPath, prefix_len);
- g_string_append_printf(aOutPath, "%02X%02X%02X%02X%02X%02X%02X%02X",
- data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7]);
- out = foil_output_file_new_open(aOutPath->str);
+ out = foil_output_file_new_open(generateId(aOutPath));
}
HASSERT(out);
return out;
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/src/FoilAuth.h
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2019-2022 Jolla Ltd.
- * Copyright (C) 2019-2022 Slava Monich <slava@monich.com>
+ * Copyright (C) 2019-2023 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -86,6 +86,7 @@
static QSize toSize(QVariant);
static QString toBase32(QByteArray, bool aLowerCase = true);
static QByteArray toByteArray(GBytes*);
+ static const char* generateId(GString*);
static FoilOutput* createFoilFile(const QString, GString*);
static QString createEmptyFoilFile(const QString);
static QString migrationUri(const QByteArray);
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/src/FoilAuthGroupModel.cpp
^
|
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2023 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of BSD license as follows:
+ *
+ * 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 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.
+ */
+
+#include "FoilAuthGroupModel.h"
+#include "FoilAuthModel.h"
+
+#include "HarbourDebug.h"
+
+// ==========================================================================
+// FoilAuthGroupModel::Private
+// ==========================================================================
+
+class FoilAuthGroupModel::Private : public QObject
+{
+ Q_OBJECT
+public:
+ Private(FoilAuthGroupModel*);
+
+ FoilAuthGroupModel* parentModel() const;
+
+public Q_SLOTS:
+ void checkCount();
+
+public:
+ int iLastKnownCount;
+};
+
+FoilAuthGroupModel::Private::Private(
+ FoilAuthGroupModel* aParent) :
+ QObject(aParent),
+ iLastKnownCount(0)
+{
+ connect(aParent, SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(checkCount()));
+ connect(aParent, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(checkCount()));
+ connect(aParent, SIGNAL(modelReset()), SLOT(checkCount()));
+}
+
+inline
+FoilAuthGroupModel*
+FoilAuthGroupModel::Private::parentModel() const
+{
+ return qobject_cast<FoilAuthGroupModel*>(parent());
+}
+
+void
+FoilAuthGroupModel::Private::checkCount()
+{
+ FoilAuthGroupModel* model = parentModel();
+ const int count = model->rowCount();
+
+ if (iLastKnownCount != count) {
+ iLastKnownCount = count;
+ HDEBUG(count);
+ Q_EMIT model->countChanged();
+ }
+}
+
+// ==========================================================================
+// FoilAuthGroupModel
+// ==========================================================================
+
+FoilAuthGroupModel::FoilAuthGroupModel(
+ QObject* aParent) :
+ QSortFilterProxyModel(aParent),
+ iPrivate(new Private(this))
+{
+ connect(this, SIGNAL(sourceModelChanged()), SIGNAL(sourceModelObjectChanged()));
+}
+
+void
+FoilAuthGroupModel::setSourceModelObject(
+ QObject* aModel)
+{
+ QAbstractItemModel* model = qobject_cast<QAbstractItemModel*>(aModel);
+ if (sourceModel() != model) {
+ HDEBUG(aModel);
+ setSourceModel(model);
+ }
+}
+
+bool
+FoilAuthGroupModel::filterAcceptsRow(
+ int aSourceRow,
+ const QModelIndex& aParent) const
+{
+ const QAbstractItemModel* model = sourceModel();
+ const QModelIndex index = model->index(aSourceRow, 0, aParent);
+
+ return model->data(index, FoilAuthModel::groupHeaderRole()).toBool();
+}
+
+#include "FoilAuthGroupModel.moc"
|
[-]
[+]
|
Added |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/src/FoilAuthGroupModel.h
^
|
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2023 Slava Monich <slava@monich.com>
+ *
+ * You may use this file under the terms of BSD license as follows:
+ *
+ * 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 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.
+ */
+
+#ifndef FOILAUTH_GROUP_MODEL_H
+#define FOILAUTH_GROUP_MODEL_H
+
+#include <QtQml>
+#include <QSortFilterProxyModel>
+
+class FoilAuthGroupModel : public QSortFilterProxyModel
+{
+ Q_OBJECT
+ Q_PROPERTY(QObject* sourceModel READ sourceModel WRITE setSourceModelObject NOTIFY sourceModelObjectChanged)
+ Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
+
+public:
+ FoilAuthGroupModel(QObject* aParent = Q_NULLPTR);
+
+ void setSourceModelObject(QObject*);
+
+protected:
+ bool filterAcceptsRow(int, const QModelIndex&) const Q_DECL_OVERRIDE;
+
+Q_SIGNALS:
+ void sourceModelObjectChanged();
+ void countChanged();
+
+private:
+ class Private;
+ Private* iPrivate;
+};
+
+QML_DECLARE_TYPE(FoilAuthGroupModel)
+
+#endif // FOILAUTH_GROUP_MODEL_H
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/src/FoilAuthModel.cpp
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2019-2022 Jolla Ltd.
- * Copyright (C) 2019-2022 Slava Monich <slava@monich.com>
+ * Copyright (C) 2019-2023 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -47,6 +47,7 @@
#include "foilmsg.h"
#include "gutil_misc.h"
+#include "gutil_strv.h"
#include <QDir>
#include <QFile>
@@ -86,10 +87,17 @@
#define INFO_ORDER_HEADER "Order"
#define INFO_ORDER_DELIMITER ','
#define INFO_ORDER_DELIMITER_S ","
+#define INFO_GROUPS_HEADER "Groups"
+#define INFO_GROUPS_DELIMITER INFO_ORDER_DELIMITER
+#define INFO_GROUPS_DELIMITER_S INFO_ORDER_DELIMITER_S
+#define INFO_GROUP_DELIMITER ':'
+#define INFO_GROUP_DELIMITER_S ":"
// Model roles
#define FOILAUTH_ROLES_(first,role,last) \
first(ModelId,modelId) \
+ role(GroupHeader,groupHeader) \
+ role(Hidden,hidden) \
role(Favorite,favorite) \
role(Type,type) \
role(Secret,secret) \
@@ -117,7 +125,6 @@
static const FoilMsgEncryptOptions* encryptionOptions(FoilMsgEncryptOptions*);
};
-
const FoilMsgEncryptOptions*
FoilAuthModel::Util::encryptionOptions(
FoilMsgEncryptOptions* aOpt)
@@ -155,9 +162,11 @@
DigestAlgorithm aAlgorithm = DEFAULT_ALGORITHM,
bool aFavorite = true);
ModelData(const QString, const FoilAuthToken&, bool aFavorite = true);
+ ModelData(const QString, const QString, bool aHidden = false);
QVariant get(Role aRole) const;
- const QString label() { return iToken.label(); }
+ bool isGroupHeader() const { return !iToken.isValid(); }
+ const QString label() const;
void setTokenPath(QString aPath);
static AuthType headerAuthType(const FoilMsg*);
@@ -170,6 +179,8 @@
public:
QString iPath;
QString iId;
+ QString iGroupLabel;
+ bool iHidden;
bool iFavorite;
FoilAuthToken iToken;
QString iPrevPassword;
@@ -190,6 +201,7 @@
bool aFavorite) :
iPath(aPath),
iId(QFileInfo(aPath).fileName()),
+ iHidden(false),
iFavorite(aFavorite),
iToken(aType, aSecret, aLabel, aIssuer, aDigits, aCounter, aTimeShift, aAlgorithm)
{
@@ -202,12 +214,31 @@
bool aFavorite) :
iPath(aPath),
iId(QFileInfo(aPath).fileName()),
+ iHidden(false),
iFavorite(aFavorite),
iToken(aToken)
{
HDEBUG(iToken.secretBase32() << iToken.label());
}
+FoilAuthModel::ModelData::ModelData(
+ const QString aId,
+ const QString aLabel,
+ bool aHidden) :
+ iId(aId),
+ iGroupLabel(aLabel),
+ iHidden(aHidden),
+ iFavorite(false)
+{
+ HDEBUG("Group" << aLabel);
+}
+
+const QString
+FoilAuthModel::ModelData::label() const
+{
+ return isGroupHeader() ? iGroupLabel : iToken.label();
+}
+
void
FoilAuthModel::ModelData::setTokenPath(
QString aPath)
@@ -222,6 +253,8 @@
{
switch (aRole) {
case ModelIdRole: return iId;
+ case GroupHeaderRole: return isGroupHeader();
+ case HiddenRole: return iHidden;
case FavoriteRole: return iFavorite;
case SecretRole: return iToken.secretBase32();
case IssuerRole: return iToken.issuer();
@@ -230,7 +263,7 @@
case AlgorithmRole: return (int)iToken.algorithm();
case CounterRole: return iToken.counter();
case TimeshiftRole: return iToken.timeshift();
- case LabelRole: return iToken.label();
+ case LabelRole: return label();
case PrevPasswordRole: return iPrevPassword;
case CurrentPasswordRole: return iCurrentPassword;
case NextPasswordRole: return iNextPassword;
@@ -311,7 +344,7 @@
{
const char* str = foilmsg_get_value(aMsg, aKey);
int value = 0;
- return gutil_parse_int(str, 10, &value) && value;
+ return gutil_parse_int(str, 10, &value) ? (value != 0) : aDefault;
}
// ==========================================================================
@@ -333,23 +366,34 @@
public:
QStringList iOrder;
+ QHash<QString,QString> iGroups;
+ QSet<QString> iHiddenGroups;
};
FoilAuthModel::ModelInfo::ModelInfo(
const ModelInfo& aInfo) :
- iOrder(aInfo.iOrder)
+ iOrder(aInfo.iOrder),
+ iGroups(aInfo.iGroups),
+ iHiddenGroups(aInfo.iHiddenGroups)
{
}
FoilAuthModel::ModelInfo::ModelInfo(
-const ModelData::List aData)
+ const ModelData::List aData)
{
const int n = aData.count();
if (n > 0) {
iOrder.reserve(n);
for (int i = 0; i < n; i++) {
const ModelData* data = aData.at(i);
- iOrder.append(QFileInfo(data->iPath).fileName());
+
+ iOrder.append(data->iId);
+ if (data->isGroupHeader()) {
+ iGroups.insert(data->iId, data->iGroupLabel);
+ if (data->iHidden) {
+ iHiddenGroups.insert(data->iId);
+ }
+ }
}
}
}
@@ -358,13 +402,42 @@
const FoilMsg* aMsg)
{
const char* order = foilmsg_get_value(aMsg, INFO_ORDER_HEADER);
+
if (order) {
char** strv = g_strsplit(order, INFO_ORDER_DELIMITER_S, -1);
+
+ HDEBUG(order);
for (char** ptr = strv; *ptr; ptr++) {
iOrder.append(g_strstrip(*ptr));
}
g_strfreev(strv);
- HDEBUG(order);
+ }
+
+ const char* groups = foilmsg_get_value(aMsg, INFO_GROUPS_HEADER);
+
+ if (groups) {
+ char** strv = g_strsplit(groups, INFO_GROUPS_DELIMITER_S, -1);
+
+ HDEBUG(groups);
+ for (char** ptr = strv; *ptr; ptr++) {
+ char** info = g_strsplit(g_strstrip(*ptr), INFO_GROUP_DELIMITER_S, -1);
+ const guint n = gutil_strv_length(info);
+
+ if (n >= 2) {
+ guint visible = TRUE;
+
+ QString id(QString::fromLocal8Bit(info[0]));
+ QString label(QString::fromUtf8(QByteArray::fromHex(info[1])));
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/src/FoilAuthModel.h
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2019-2022 Jolla Ltd.
- * Copyright (C) 2019-2022 Slava Monich <slava@monich.com>
+ * Copyright (C) 2019-2023 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -53,6 +53,7 @@
Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
Q_PROPERTY(bool keyAvailable READ keyAvailable NOTIFY keyAvailableChanged)
Q_PROPERTY(bool timerActive READ timerActive NOTIFY timerActiveChanged)
+ Q_PROPERTY(QList<int> groupHeaderRows READ groupHeaderRows NOTIFY groupHeaderRowsChanged)
Q_PROPERTY(FoilState foilState READ foilState NOTIFY foilStateChanged)
Q_DISABLE_COPY(FoilAuthModel)
@@ -61,7 +62,6 @@
class ModelData;
class BaseTask;
class SaveInfoTask;
- class SaveTokenTask;
class GenerateKeyTask;
class DecryptTask;
class EncryptTask;
@@ -87,12 +87,14 @@
static int typeRole();
static int favoriteRole();
+ static int groupHeaderRole();
int period() const;
int timeLeft() const;
bool busy() const;
bool keyAvailable() const;
bool timerActive() const;
+ QList<int> groupHeaderRows() const;
FoilState foilState() const;
int indexOf(FoilAuthToken) const;
@@ -106,13 +108,15 @@
Q_INVOKABLE void lock(bool aTimeout);
Q_INVOKABLE bool unlock(const QString aPassword);
+ Q_INVOKABLE void addGroup(const QString);
Q_INVOKABLE bool addToken(int aType, const QString aTokenBase32,
const QString aLabel, const QString aIssuer, int aDigits,
int aCounter, int aTimeShift, int aAlgorithm);
Q_INVOKABLE void addTokens(const QList<FoilAuthToken>);
+ Q_INVOKABLE void deleteGroupItem(const QString);
Q_INVOKABLE void deleteToken(const QString);
Q_INVOKABLE void deleteTokens(const QStringList);
- Q_INVOKABLE void deleteAll();
+ Q_INVOKABLE QList<int> itemRowsForGroupAt(int) const;
Q_INVOKABLE QStringList getIdsAt(const QList<int>) const;
Q_INVOKABLE QStringList generateMigrationUris(const QList<int>) const;
@@ -132,6 +136,7 @@
void busyChanged();
void keyAvailableChanged();
void timerActiveChanged();
+ void groupHeaderRowsChanged();
void foilStateChanged();
void timeLeftChanged();
void keyGenerated();
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/src/main.cpp
^
|
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2019-2022 Jolla Ltd.
- * Copyright (C) 2019-2022 Slava Monich <slava@monich.com>
+ * Copyright (C) 2019-2023 Slava Monich <slava@monich.com>
*
* You may use this file under the terms of BSD license as follows:
*
@@ -33,6 +33,7 @@
#include "FoilAuthDefs.h"
#include "FoilAuthFavoritesModel.h"
+#include "FoilAuthGroupModel.h"
#include "FoilAuthImportModel.h"
#include "FoilAuthModel.h"
#include "FoilAuthSettings.h"
@@ -78,6 +79,7 @@
REGISTER_SINGLETON_TYPE(uri, v1, v2, FoilAuth);
REGISTER_SINGLETON_TYPE(uri, v1, v2, SailOTP);
REGISTER_TYPE(uri, v1, v2, FoilAuthFavoritesModel);
+ REGISTER_TYPE(uri, v1, v2, FoilAuthGroupModel);
REGISTER_TYPE(uri, v1, v2, FoilAuthImportModel);
REGISTER_TYPE(uri, v1, v2, HarbourOrganizeListModel);
REGISTER_TYPE(uri, v1, v2, HarbourQrCodeGenerator);
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/translations/harbour-foilauth-de.ts
^
|
@@ -247,10 +247,10 @@
<extracomment>Pulley menu item, changes Foil password</extracomment>
<translation>Passwort ändern</translation>
</message>
- <message id="foilauth-menu-lock">
- <source>Lock</source>
- <extracomment>Pulley menu item, locks the tokens</extracomment>
- <translation>Sperren</translation>
+ <message id="foilauth-menu-organize">
+ <source>Organize</source>
+ <extracomment>Pulley menu item, opens organize page</extracomment>
+ <translation type="unfinished">Organisieren</translation>
</message>
<message id="foilauth-menu-select_tokens">
<source>Select</source>
@@ -407,6 +407,51 @@
<extracomment>Dialog title</extracomment>
<translation type="unfinished">Wählen die hinzuzufügenden Token aus</translation>
</message>
+ <message id="foilauth-organize-groups-title">
+ <source>Manage groups</source>
+ <extracomment>Page header title</extracomment>
+ <translation type="unfinished">Gruppen verwalten</translation>
+ </message>
+ <message id="foilauth-organize-groups-description">
+ <source>Create, delete and rename groups</source>
+ <extracomment>Page header descriptions</extracomment>
+ <translation type="unfinished">Gruppen erstellen, löschen und umbenennen</translation>
+ </message>
+ <message id="foilauth-organize-groups-menu-rename">
+ <source>Rename</source>
+ <extracomment>Context menu item</extracomment>
+ <translation type="unfinished">Umbenennen</translation>
+ </message>
+ <message id="foilauth-organize-groups-menu-delete">
+ <source>Delete</source>
+ <extracomment>Context menu item</extracomment>
+ <translation type="unfinished">Löschen</translation>
+ </message>
+ <message id="foilauth-organize-groups-remorse-deleting">
+ <source>Deleting</source>
+ <extracomment>Remorse item label</extracomment>
+ <translation type="unfinished">Lösche</translation>
+ </message>
+ <message id="foilauth-organize-groups-add_group">
+ <source>Add group</source>
+ <extracomment>List footer button label</extracomment>
+ <translation type="unfinished">Gruppe hinzufügen</translation>
+ </message>
+ <message id="foilauth-organize-groups-new_group">
+ <source>New group</source>
+ <extracomment>Default name for the new group</extracomment>
+ <translation type="unfinished">Neue Gruppe</translation>
+ </message>
+ <message id="foilauth-organize-tokens-title">
+ <source>Organize tokens</source>
+ <extracomment>Page header title</extracomment>
+ <translation type="unfinished">Token organisieren</translation>
+ </message>
+ <message id="foilauth-organize-tokens-description">
+ <source>Press, hold and drag to reorder</source>
+ <extracomment>Page header descriptions</extracomment>
+ <translation type="unfinished">Zum Neuordnen drücken, halten und ziehen</translation>
+ </message>
<message id="foilauth-settings_page-header-version">
<source>Version %1</source>
<extracomment>Settings page header description (app version)</extracomment>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/translations/harbour-foilauth-fr.ts
^
|
@@ -247,10 +247,10 @@
<extracomment>Pulley menu item, changes Foil password</extracomment>
<translation>Modifier le mot de passe</translation>
</message>
- <message id="foilauth-menu-lock">
- <source>Lock</source>
- <extracomment>Pulley menu item, locks the tokens</extracomment>
- <translation>Verrouiller</translation>
+ <message id="foilauth-menu-organize">
+ <source>Organize</source>
+ <extracomment>Pulley menu item, opens organize page</extracomment>
+ <translation type="unfinished">Organiser</translation>
</message>
<message id="foilauth-menu-new_auth_token">
<source>Add token</source>
@@ -407,6 +407,51 @@
<extracomment>Dialog title</extracomment>
<translation type="unfinished">Sélectionnez les jetons à ajouter</translation>
</message>
+ <message id="foilauth-organize-groups-title">
+ <source>Manage groups</source>
+ <extracomment>Page header title</extracomment>
+ <translation type="unfinished">Gérer les groupes</translation>
+ </message>
+ <message id="foilauth-organize-groups-description">
+ <source>Create, delete and rename groups</source>
+ <extracomment>Page header descriptions</extracomment>
+ <translation type="unfinished">Créer, supprimer et renommer des groupes</translation>
+ </message>
+ <message id="foilauth-organize-groups-menu-rename">
+ <source>Rename</source>
+ <extracomment>Context menu item</extracomment>
+ <translation type="unfinished">Renommer</translation>
+ </message>
+ <message id="foilauth-organize-groups-menu-delete">
+ <source>Delete</source>
+ <extracomment>Context menu item</extracomment>
+ <translation type="unfinished">Supprimer</translation>
+ </message>
+ <message id="foilauth-organize-groups-remorse-deleting">
+ <source>Deleting</source>
+ <extracomment>Remorse item label</extracomment>
+ <translation type="unfinished">Suppression</translation>
+ </message>
+ <message id="foilauth-organize-groups-add_group">
+ <source>Add group</source>
+ <extracomment>List footer button label</extracomment>
+ <translation type="unfinished">Ajouter un groupe</translation>
+ </message>
+ <message id="foilauth-organize-groups-new_group">
+ <source>New group</source>
+ <extracomment>Default name for the new group</extracomment>
+ <translation type="unfinished">Nouveau groupe</translation>
+ </message>
+ <message id="foilauth-organize-tokens-title">
+ <source>Organize tokens</source>
+ <extracomment>Page header title</extracomment>
+ <translation type="unfinished">Organiser les jetons</translation>
+ </message>
+ <message id="foilauth-organize-tokens-description">
+ <source>Press, hold and drag to reorder</source>
+ <extracomment>Page header descriptions</extracomment>
+ <translation type="unfinished">Appuyez, maintenez et faites glisser pour réorganiser</translation>
+ </message>
<message id="foilauth-settings_page-header-version">
<source>Version %1</source>
<extracomment>Settings page header description (app version)</extracomment>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/translations/harbour-foilauth-hu.ts
^
|
@@ -244,10 +244,10 @@
<extracomment>Pulley menu item, changes Foil password</extracomment>
<translation>Jelszóváltoztatás</translation>
</message>
- <message id="foilauth-menu-lock">
- <source>Lock</source>
- <extracomment>Pulley menu item, locks the tokens</extracomment>
- <translation>Zárolás</translation>
+ <message id="foilauth-menu-organize">
+ <source>Organize</source>
+ <extracomment>Pulley menu item, opens organize page</extracomment>
+ <translation type="unfinished">Szervez</translation>
</message>
<message id="foilauth-menu-new_auth_token">
<source>Add token</source>
@@ -404,6 +404,51 @@
<extracomment>Dialog title</extracomment>
<translation type="unfinished">Válassza ki a hozzáadni kívánt tokeneket</translation>
</message>
+ <message id="foilauth-organize-groups-title">
+ <source>Manage groups</source>
+ <extracomment>Page header title</extracomment>
+ <translation type="unfinished">Csoportok kezelése</translation>
+ </message>
+ <message id="foilauth-organize-groups-description">
+ <source>Create, delete and rename groups</source>
+ <extracomment>Page header descriptions</extracomment>
+ <translation type="unfinished">Csoportok létrehozása, törlése és átnevezése</translation>
+ </message>
+ <message id="foilauth-organize-groups-menu-rename">
+ <source>Rename</source>
+ <extracomment>Context menu item</extracomment>
+ <translation type="unfinished">Átnevezés</translation>
+ </message>
+ <message id="foilauth-organize-groups-menu-delete">
+ <source>Delete</source>
+ <extracomment>Context menu item</extracomment>
+ <translation type="unfinished">Törlés</translation>
+ </message>
+ <message id="foilauth-organize-groups-remorse-deleting">
+ <source>Deleting</source>
+ <extracomment>Remorse item label</extracomment>
+ <translation type="unfinished">Törlés</translation>
+ </message>
+ <message id="foilauth-organize-groups-add_group">
+ <source>Add group</source>
+ <extracomment>List footer button label</extracomment>
+ <translation type="unfinished">Csoport hozzáadása</translation>
+ </message>
+ <message id="foilauth-organize-groups-new_group">
+ <source>New group</source>
+ <extracomment>Default name for the new group</extracomment>
+ <translation type="unfinished">Új csoport</translation>
+ </message>
+ <message id="foilauth-organize-tokens-title">
+ <source>Organize tokens</source>
+ <extracomment>Page header title</extracomment>
+ <translation type="unfinished">Rendszerezd a tokenekeket</translation>
+ </message>
+ <message id="foilauth-organize-tokens-description">
+ <source>Press, hold and drag to reorder</source>
+ <extracomment>Page header descriptions</extracomment>
+ <translation type="unfinished">Nyomja meg, tartsa lenyomva és húzza az átrendezéshez</translation>
+ </message>
<message id="foilauth-settings_page-header-version">
<source>Version %1</source>
<extracomment>Settings page header description (app version)</extracomment>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/translations/harbour-foilauth-pl.ts
^
|
@@ -195,7 +195,7 @@
<message id="foilauth-scan-skip_button">
<source>Skip</source>
<extracomment>Button label (skip scanning)</extracomment>
- <translation type="unfinished">Pomiń</translation>
+ <translation>Pomiń</translation>
</message>
<message id="foilauth-foil_apps_warning">
<source>Note that all Foil apps use the same encryption key and password.</source>
@@ -250,10 +250,10 @@
<extracomment>Pulley menu item, changes Foil password</extracomment>
<translation>Zmień hasło</translation>
</message>
- <message id="foilauth-menu-lock">
- <source>Lock</source>
- <extracomment>Pulley menu item, locks the tokens</extracomment>
- <translation>Zablokuj</translation>
+ <message id="foilauth-menu-organize">
+ <source>Organize</source>
+ <extracomment>Pulley menu item, opens organize page</extracomment>
+ <translation>Porządkuj</translation>
</message>
<message id="foilauth-menu-select_tokens">
<source>Select</source>
@@ -408,7 +408,52 @@
<message id="foilauth-select_tokens-title-add_tokens">
<source>Select tokens to add</source>
<extracomment>Dialog title</extracomment>
- <translation type="unfinished">Wybierz żądane tokeny</translation>
+ <translation>Wybierz tokeny, które chcesz dodać</translation>
+ </message>
+ <message id="foilauth-organize-groups-title">
+ <source>Manage groups</source>
+ <extracomment>Page header title</extracomment>
+ <translation type="unfinished">Zarządzanie grupami</translation>
+ </message>
+ <message id="foilauth-organize-groups-description">
+ <source>Create, delete and rename groups</source>
+ <extracomment>Page header descriptions</extracomment>
+ <translation type="unfinished">Twórz, usuwaj i zmieniaj nazwy grup</translation>
+ </message>
+ <message id="foilauth-organize-groups-menu-rename">
+ <source>Rename</source>
+ <extracomment>Context menu item</extracomment>
+ <translation type="unfinished">Przemianować</translation>
+ </message>
+ <message id="foilauth-organize-groups-menu-delete">
+ <source>Delete</source>
+ <extracomment>Context menu item</extracomment>
+ <translation>Usuń</translation>
+ </message>
+ <message id="foilauth-organize-groups-remorse-deleting">
+ <source>Deleting</source>
+ <extracomment>Remorse item label</extracomment>
+ <translation>Usuwanie</translation>
+ </message>
+ <message id="foilauth-organize-groups-add_group">
+ <source>Add group</source>
+ <extracomment>List footer button label</extracomment>
+ <translation type="unfinished">Dodaj grupę</translation>
+ </message>
+ <message id="foilauth-organize-groups-new_group">
+ <source>New group</source>
+ <extracomment>Default name for the new group</extracomment>
+ <translation type="unfinished">Nowa grupa</translation>
+ </message>
+ <message id="foilauth-organize-tokens-title">
+ <source>Organize tokens</source>
+ <extracomment>Page header title</extracomment>
+ <translation type="unfinished">Uporządkuj tokeny</translation>
+ </message>
+ <message id="foilauth-organize-tokens-description">
+ <source>Press, hold and drag to reorder</source>
+ <extracomment>Page header descriptions</extracomment>
+ <translation type="unfinished">Naciśnij, przytrzymaj i przeciągnij, aby zmienić kolejność</translation>
</message>
<message id="foilauth-settings_page-header-version">
<source>Version %1</source>
@@ -418,12 +463,12 @@
<message id="foilauth-settings_page-autolock-text">
<source>Automatic locking</source>
<extracomment>Text switch label</extracomment>
- <translation type="unfinished">Automatyczne blokowanie</translation>
+ <translation>Automatyczne blokowanie</translation>
</message>
<message id="foilauth-settings_page-autolock-description">
<source>Require to enter Foil password after unlocking the screen.</source>
<extracomment>Text switch description</extracomment>
- <translation type="unfinished">Wymagaj podania Foil hasła po odblokowaniu ekranu.</translation>
+ <translation>Wymagaj podania Foil hasła po odblokowaniu ekranu.</translation>
</message>
<message id="jail-explanation">
<source>This application is not designed to function in a sandbox. Try installing the latest version from <b><a href='%1'>OpenRepos</a></b> or <b><a href='%2'>GitHub</a></b>, it may implement some sort of a workaround. No guarantee, though.</source>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/translations/harbour-foilauth-ru.ts
^
|
@@ -250,10 +250,10 @@
<extracomment>Pulley menu item, changes Foil password</extracomment>
<translation>Поменять пароль</translation>
</message>
- <message id="foilauth-menu-lock">
- <source>Lock</source>
- <extracomment>Pulley menu item, locks the tokens</extracomment>
- <translation>Заблокировать</translation>
+ <message id="foilauth-menu-organize">
+ <source>Organize</source>
+ <extracomment>Pulley menu item, opens organize page</extracomment>
+ <translation>Упорядочить</translation>
</message>
<message id="foilauth-menu-select_tokens">
<source>Select</source>
@@ -410,6 +410,51 @@
<extracomment>Dialog title</extracomment>
<translation>Выберите нужные коды</translation>
</message>
+ <message id="foilauth-organize-groups-title">
+ <source>Manage groups</source>
+ <extracomment>Page header title</extracomment>
+ <translation>Управление группами</translation>
+ </message>
+ <message id="foilauth-organize-groups-description">
+ <source>Create, delete and rename groups</source>
+ <extracomment>Page header descriptions</extracomment>
+ <translation>Создание, удаление и переименование</translation>
+ </message>
+ <message id="foilauth-organize-groups-menu-rename">
+ <source>Rename</source>
+ <extracomment>Context menu item</extracomment>
+ <translation>Переименовать</translation>
+ </message>
+ <message id="foilauth-organize-groups-menu-delete">
+ <source>Delete</source>
+ <extracomment>Context menu item</extracomment>
+ <translation>Удалить</translation>
+ </message>
+ <message id="foilauth-organize-groups-remorse-deleting">
+ <source>Deleting</source>
+ <extracomment>Remorse item label</extracomment>
+ <translation>Удаление</translation>
+ </message>
+ <message id="foilauth-organize-groups-add_group">
+ <source>Add group</source>
+ <extracomment>List footer button label</extracomment>
+ <translation>Добавить группу</translation>
+ </message>
+ <message id="foilauth-organize-groups-new_group">
+ <source>New group</source>
+ <extracomment>Default name for the new group</extracomment>
+ <translation>Новая группа</translation>
+ </message>
+ <message id="foilauth-organize-tokens-title">
+ <source>Organize tokens</source>
+ <extracomment>Page header title</extracomment>
+ <translation>Поменять порядок</translation>
+ </message>
+ <message id="foilauth-organize-tokens-description">
+ <source>Press, hold and drag to reorder</source>
+ <extracomment>Page header descriptions</extracomment>
+ <translation>Жмите на всё и таскайте с места на место</translation>
+ </message>
<message id="foilauth-settings_page-header-version">
<source>Version %1</source>
<extracomment>Settings page header description (app version)</extracomment>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/translations/harbour-foilauth-sv.ts
^
|
@@ -248,10 +248,10 @@
<extracomment>Pulley menu item, changes Foil password</extracomment>
<translation>Ändra lösenord</translation>
</message>
- <message id="foilauth-menu-lock">
- <source>Lock</source>
- <extracomment>Pulley menu item, locks the tokens</extracomment>
- <translation>Lås</translation>
+ <message id="foilauth-menu-organize">
+ <source>Organize</source>
+ <extracomment>Pulley menu item, opens organize page</extracomment>
+ <translation>Organisera</translation>
</message>
<message id="foilauth-menu-new_auth_token">
<source>Add token</source>
@@ -408,6 +408,51 @@
<extracomment>Dialog title</extracomment>
<translation type="unfinished">Välj tokens att lägga till</translation>
</message>
+ <message id="foilauth-organize-groups-title">
+ <source>Manage groups</source>
+ <extracomment>Page header title</extracomment>
+ <translation type="unfinished">Hantera grupper</translation>
+ </message>
+ <message id="foilauth-organize-groups-description">
+ <source>Create, delete and rename groups</source>
+ <extracomment>Page header descriptions</extracomment>
+ <translation type="unfinished">Skapa, ta bort och byt namn på grupper</translation>
+ </message>
+ <message id="foilauth-organize-groups-menu-rename">
+ <source>Rename</source>
+ <extracomment>Context menu item</extracomment>
+ <translation type="unfinished">Döp om</translation>
+ </message>
+ <message id="foilauth-organize-groups-menu-delete">
+ <source>Delete</source>
+ <extracomment>Context menu item</extracomment>
+ <translation type="unfinished">Ta bort</translation>
+ </message>
+ <message id="foilauth-organize-groups-remorse-deleting">
+ <source>Deleting</source>
+ <extracomment>Remorse item label</extracomment>
+ <translation type="unfinished">Tar bort</translation>
+ </message>
+ <message id="foilauth-organize-groups-add_group">
+ <source>Add group</source>
+ <extracomment>List footer button label</extracomment>
+ <translation type="unfinished">Lägg till grupp</translation>
+ </message>
+ <message id="foilauth-organize-groups-new_group">
+ <source>New group</source>
+ <extracomment>Default name for the new group</extracomment>
+ <translation type="unfinished">Ny grupp</translation>
+ </message>
+ <message id="foilauth-organize-tokens-title">
+ <source>Organize tokens</source>
+ <extracomment>Page header title</extracomment>
+ <translation type="unfinished">Organisera tokens</translation>
+ </message>
+ <message id="foilauth-organize-tokens-description">
+ <source>Press, hold and drag to reorder</source>
+ <extracomment>Page header descriptions</extracomment>
+ <translation type="unfinished">Tryck, håll och dra för att ändra ordning</translation>
+ </message>
<message id="foilauth-settings_page-header-version">
<source>Version %1</source>
<extracomment>Settings page header description (app version)</extracomment>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/translations/harbour-foilauth-zh_CN.ts
^
|
@@ -245,10 +245,10 @@
<extracomment>Pulley menu item, changes Foil password</extracomment>
<translation>更改密码</translation>
</message>
- <message id="foilauth-menu-lock">
- <source>Lock</source>
- <extracomment>Pulley menu item, locks the tokens</extracomment>
- <translation>锁定</translation>
+ <message id="foilauth-menu-organize">
+ <source>Organize</source>
+ <extracomment>Pulley menu item, opens organize page</extracomment>
+ <translation type="unfinished">组织</translation>
</message>
<message id="foilauth-menu-new_auth_token">
<source>Add token</source>
@@ -405,6 +405,51 @@
<extracomment>Dialog title</extracomment>
<translation type="unfinished">选择要添加的令牌</translation>
</message>
+ <message id="foilauth-organize-groups-title">
+ <source>Manage groups</source>
+ <extracomment>Page header title</extracomment>
+ <translation type="unfinished">管理群组</translation>
+ </message>
+ <message id="foilauth-organize-groups-description">
+ <source>Create, delete and rename groups</source>
+ <extracomment>Page header descriptions</extracomment>
+ <translation type="unfinished">创建、删除和重命名组</translation>
+ </message>
+ <message id="foilauth-organize-groups-menu-rename">
+ <source>Rename</source>
+ <extracomment>Context menu item</extracomment>
+ <translation type="unfinished">改名</translation>
+ </message>
+ <message id="foilauth-organize-groups-menu-delete">
+ <source>Delete</source>
+ <extracomment>Context menu item</extracomment>
+ <translation type="unfinished">删除</translation>
+ </message>
+ <message id="foilauth-organize-groups-remorse-deleting">
+ <source>Deleting</source>
+ <extracomment>Remorse item label</extracomment>
+ <translation type="unfinished">删除</translation>
+ </message>
+ <message id="foilauth-organize-groups-add_group">
+ <source>Add group</source>
+ <extracomment>List footer button label</extracomment>
+ <translation type="unfinished">添加新组</translation>
+ </message>
+ <message id="foilauth-organize-groups-new_group">
+ <source>New group</source>
+ <extracomment>Default name for the new group</extracomment>
+ <translation type="unfinished">新建群组</translation>
+ </message>
+ <message id="foilauth-organize-tokens-title">
+ <source>Organize tokens</source>
+ <extracomment>Page header title</extracomment>
+ <translation type="unfinished">整理代币</translation>
+ </message>
+ <message id="foilauth-organize-tokens-description">
+ <source>Press, hold and drag to reorder</source>
+ <extracomment>Page header descriptions</extracomment>
+ <translation type="unfinished">按住并拖动以重新排序</translation>
+ </message>
<message id="foilauth-settings_page-header-version">
<source>Version %1</source>
<extracomment>Settings page header description (app version)</extracomment>
|
[-]
[+]
|
Changed |
_service:tar_git:harbour-foilauth-1.1.5.tar.gz/translations/harbour-foilauth.ts
^
|
@@ -247,10 +247,10 @@
<extracomment>Pulley menu item, changes Foil password</extracomment>
<translation>Change password</translation>
</message>
- <message id="foilauth-menu-lock">
- <source>Lock</source>
- <extracomment>Pulley menu item, locks the tokens</extracomment>
- <translation>Lock</translation>
+ <message id="foilauth-menu-organize">
+ <source>Organize</source>
+ <extracomment>Pulley menu item, opens organize page</extracomment>
+ <translation>Organize</translation>
</message>
<message id="foilauth-menu-select_tokens">
<source>Select</source>
@@ -407,6 +407,51 @@
<extracomment>Dialog title</extracomment>
<translation>Select tokens to add</translation>
</message>
+ <message id="foilauth-organize-groups-title">
+ <source>Manage groups</source>
+ <extracomment>Page header title</extracomment>
+ <translation>Manage groups</translation>
+ </message>
+ <message id="foilauth-organize-groups-description">
+ <source>Create, delete and rename groups</source>
+ <extracomment>Page header descriptions</extracomment>
+ <translation>Create, delete and rename groups</translation>
+ </message>
+ <message id="foilauth-organize-groups-menu-rename">
+ <source>Rename</source>
+ <extracomment>Context menu item</extracomment>
+ <translation>Rename</translation>
+ </message>
+ <message id="foilauth-organize-groups-menu-delete">
+ <source>Delete</source>
+ <extracomment>Context menu item</extracomment>
+ <translation>Delete</translation>
+ </message>
+ <message id="foilauth-organize-groups-remorse-deleting">
+ <source>Deleting</source>
+ <extracomment>Remorse item label</extracomment>
+ <translation>Deleting</translation>
+ </message>
+ <message id="foilauth-organize-groups-add_group">
+ <source>Add group</source>
+ <extracomment>List footer button label</extracomment>
+ <translation>Add group</translation>
+ </message>
+ <message id="foilauth-organize-groups-new_group">
+ <source>New group</source>
+ <extracomment>Default name for the new group</extracomment>
+ <translation>New group</translation>
+ </message>
+ <message id="foilauth-organize-tokens-title">
+ <source>Organize tokens</source>
+ <extracomment>Page header title</extracomment>
+ <translation>Organize tokens</translation>
+ </message>
+ <message id="foilauth-organize-tokens-description">
+ <source>Press, hold and drag to reorder</source>
+ <extracomment>Page header descriptions</extracomment>
+ <translation>Press, hold and drag to reorder</translation>
+ </message>
<message id="foilauth-settings_page-header-version">
<source>Version %1</source>
<extracomment>Settings page header description (app version)</extracomment>
|