Bug 93221 - "object variable not set" fault with Basic using CryptographicService with 64 bit LibreOffice an 64 bit windows
Summary: "object variable not set" fault with Basic using CryptographicService with 64...
Status: RESOLVED INSUFFICIENTDATA
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
5.0.0.5 release
Hardware: Other All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: bibisectRequest, regression
Depends on:
Blocks:
 
Reported: 2015-08-07 03:17 UTC by Andrew
Modified: 2017-08-30 19:31 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Tests the MD5 cryptography - it works on any version of LibreOffice prior to any of the V5 variants (10.19 KB, application/vnd.oasis.opendocument.spreadsheet)
2015-08-21 20:02 UTC, Andrew
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew 2015-08-07 03:17:00 UTC
I downloaded and installed the latest LibreOffice 64 bit version and since I did that my cryptography Basic code does not work. It throws the "object variable not set" error message.
This code is what I use. I modified the original code because the MD5 sometimes generates shorter than 32 character code and need to be filled with a 0 at the start of the MD5 code, which is another problem in the Cryptographic service, but I removed it and put it back as the original code to make sure that not my modification cause it. It turns out that it throws the same error message that way too.
It throws the error at the line TextHash = objDecrypt.GetTextHash(strText, strAlgorithm)

When I was using it with my modification it throws the error at this line 
tempText = objDecrypt.GetTextHash(strText, strAlgorithm)

Below is the complete set of Basic code for the original functioning without the zero correction.

REM texthash(CONCATENATE(A2,"idta"),"MD5"))


REM Propósito: Computes hashes (message digests) of text and files using following hashing algorithms: MD2, MD5, SHA-1, SHA-256, SHA-384 and SHA-512
REM Informações sobre o Módulo: Módulo Padrão = basMain
REM Convenção para nomeclatura das versões: a.mm[.dd]: Nome do Revisor (e-mail)
REM Autor: Claudio Gomes Riella (cgriella@ufrgs.br)
REM Versões:
REM		1.10.01 (1º/10/2009): Claudio Gomes Riella (cgriella@ufrgs.br)
REM Parâmetros<-Argumentos:	Main
REM							FileHash(strFullPathName as String, strAlgorithm As String) <- Calc function FILEHASH(Cell; Algorithm)
REM 						TextHash(strText as String, strAlgorithm As String) <- Calc function TEXTHASH(Cell; Algorithm)
REM Resultados: return message digests
REM Requisitos mínimos: BrOffice.org 3.1.0 ou OpenOffice.org 3.1.0 + Cryptographic Service 1.10.01
REM Licença: LGPL

Sub Main
	Dim strFullPathName as String, sbNewLine as String
	sbNewLine = Chr(13) + Chr(10)
	strFullPathName = inputbox ("Insert the path of file")
	msgbox "File is """ & strFullPathName & """" & sbNewLine & "FileHash: " & FileHash(strFullPathName, "MD5") & sbNewLine & "TextHash: " & TextHash(strFullPathName, "MD5")
End Sub

Function FileHash(strFullPathName as String, strAlgorithm As String)
	Dim objDecrypt As Object
	Set objDecrypt = CreateUnoService("org.openoffice.Cryptographic.CryptographicService")
	FileHash = objDecrypt.GetFileHash(strFullPathName, strAlgorithm)
End Function

Function TextHash(strText as String, strAlgorithm As String)
	Dim objDecrypt As Object
	Dim LResult As Long
	Dim tempText As String
	Dim textLength As Integer
	Set objDecrypt = CreateUnoService("org.openoffice.Cryptographic.CryptographicService")
	
REM	tempText = objDecrypt.GetTextHash(strText, strAlgorithm)
REM	textLength = Len(tempText)
	
REM	If strAlgorithm = "MD5" Then
REM		If textLength = 32 Then
REM			tempText = ""
REM		ElseIf textLength = 31 Then
REM			tempText = "0" 
REM		ElseIf textLength = 30 Then
REM			tempText = "00"
REM		ElseIf textLength = 29 Then
REM			tempText = "000"
REM		ElseIf textLength = 28 Then
REM			tempText = "0000"
REM		ElseIf textLength = 27 Then
REM			tempText = "00000"
REM		ElseIf textLength = 26 Then
REM			tempText = "000000"
REM		End If
REM	else
REM		tempText = ""
REM	End If
	
REM	TextHash = tempText + objDecrypt.GetTextHash(strText, strAlgorithm)
	
	TextHash = objDecrypt.GetTextHash(strText, strAlgorithm)
End Function
Comment 1 raal 2015-08-21 14:36:57 UTC
Tested with Version: 5.1.0.0.alpha1+ (x64)
Build ID: e0b0501452e6a72ba800ae9f536d766f8111ed78
TinderBox: Win-x86_64@62-TDF, Branch:MASTER, Time: 2015-08-19_01:09:37
WIN7
and I get error: BASIC runtime error. Object variable not set.

on line: 	FileHash = objDecrypt.GetFileHash(strFullPathName, strAlgorithm)

I ran macro "Main" and filled path to some file on disk.


Please provide test file and step-by-step instructions how to reproduce the bug. What is the latest version where your macro works correct?
Thank you
Comment 2 Andrew 2015-08-21 20:02:06 UTC
Created attachment 118079 [details]
Tests the MD5 cryptography - it works on any version of LibreOffice prior to any of the V5 variants
Comment 3 Andrew 2015-08-21 20:03:24 UTC
The Basic code works on any version prior to version 5.
Currently I reinstated version 4.4.5.2 and the encoder works fine.

The attached file has the text to be converted: someemail@domain.com in field B2
and gives the result: 539f1ea12038c073ab9c59a01caef6ac in field B3

I cross-referenced the result with one of the online converters. The one I used was http://www.md5.cz and the result was identical to the above

I assume the attached file will throw the

BASIC runtime error. Object variable not set.

at the time when this file is opened in LibreOffice 5. I actually installed the 32 bit LibreOffice version 5 later and had the same error with that one too. 
Both 64 and 32 bit LibreOffice V5 variants generate the same error with this encryption code but on prior version of 
LibreOffice was working fine. I use this encoding on a daily basis for about 2 years now, so I would have picked up any misbehaviour on 
previous LibreOffice versions just like I did with the shorter than 32 character code generation which is another matter relating to the Cryptographic 
service.
Comment 4 Buovjaga 2016-12-16 19:15:09 UTC
Tried with test document and copied macro: it says
BASIC runtime error.
Argumentti ei ole valinnainen.

Meaning "Argument is not optional" (I have no idea, why it gives a Finnish error message even though UI is English USA)

It highlights this second to last line:
TextHash = objDecrypt.GetTextHash(strText, strAlgorithm)

Andrew: maybe you should post your question to http://ask.libreoffice.org/

Arch Linux 64-bit, KDE Plasma 5
Version: 5.4.0.0.alpha0+
Build ID: 06ea887f8ba34a628d7641eab210501f7bd2493d
CPU Threads: 8; OS Version: Linux 4.8; UI Render: default; VCL: kde4; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group
Built on December 16th 2016
Comment 5 Andrew 2016-12-17 09:13:32 UTC
(In reply to Buovjaga from comment #4)
> Tried with test document and copied macro: it says
> BASIC runtime error.
> Argumentti ei ole valinnainen.
> 
> Meaning "Argument is not optional" (I have no idea, why it gives a Finnish
> error message even though UI is English USA)
> 
> It highlights this second to last line:
> TextHash = objDecrypt.GetTextHash(strText, strAlgorithm)
> 
> Andrew: maybe you should post your question to http://ask.libreoffice.org/
> 
> Arch Linux 64-bit, KDE Plasma 5
> Version: 5.4.0.0.alpha0+
> Build ID: 06ea887f8ba34a628d7641eab210501f7bd2493d
> CPU Threads: 8; OS Version: Linux 4.8; UI Render: default; VCL: kde4; 
> Locale: fi-FI (fi_FI.UTF-8); Calc: group
> Built on December 16th 2016

Unfortunately as you confirmed this is still a problem. Still cannot use this function in any of the V5.x LibreOffice.
Comment 6 Buovjaga 2016-12-17 10:39:56 UTC
Ok, let's set to NEW then.
Comment 7 Terrence Enger 2016-12-21 16:12:16 UTC
My results are different than reported here in that all the tested
versions of LibreOffice display an error dialog.  But note that I have
done all my testing on Linux, debian-stretch.  In particular ...

(*) Local build of commit ad18926c (2016-12-10), bibisect-50max
    version oldest, and bibisect-44max version oldest display error
    message
        "object variable not set".

(*) bibisect-43max version oldest displays error message
        "argument is not optional".
Comment 8 Aron Budea 2017-01-17 04:59:36 UTC
This macro depends on extension [1]. Have you installed it in your updated LibreOffice version? Also, since the extension relies on Java, it requires 64-bit JRE in 64-bit LibreOffice.

[1] http://extensions.openoffice.org/en/project/cryptographic-hash-functions-uno-component-openofficeorg
Comment 9 QA Administrators 2017-07-27 12:06:28 UTC Comment hidden (obsolete)
Comment 10 QA Administrators 2017-08-30 19:31:42 UTC
Dear Bug Submitter,

Please read this message in its entirety before proceeding.

Your bug report is being closed as INSUFFICIENTDATA due to inactivity and
a lack of information which is needed in order to accurately
reproduce and confirm the problem. We encourage you to retest
your bug against the latest release. If the issue is still
present in the latest stable release, we need the following
information (please ignore any that you've already provided):

a) Provide details of your system including your operating
   system and the latest version of LibreOffice that you have
   confirmed the bug to be present

b) Provide easy to reproduce steps – the simpler the better

c) Provide any test case(s) which will help us confirm the problem

d) Provide screenshots of the problem if you think it might help

e) Read all comments and provide any requested information

Once all of this is done, please set the bug back to UNCONFIRMED
and we will attempt to reproduce the issue. Please do not:

a) respond via email 

b) update the version field in the bug or any of the other details
   on the top section of our bug tracker

Warm Regards,
QA Team

MassPing-NeedInfo-20170830