Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bytes output from digest command do not include algorithm #47

Closed
cwash opened this issue Jan 15, 2019 · 1 comment
Closed

Bytes output from digest command do not include algorithm #47

cwash opened this issue Jan 15, 2019 · 1 comment

Comments

@cwash
Copy link
Contributor

cwash commented Jan 15, 2019

final var key = keyPair.getPair().getPublic().getEncoded();

Shouldn't this line use keyPair.getPublic() - which seems to include the algorithm - and not just the encoded byte portion - when generating the byte array of the public key to place in your application?

When testing this, I couldn't get it to work with just the encoded byte portion. Upon attempting to load the public key in, the LicenseKeyPair.getAlgorithm() call would always fail in this code block, because it was not finding the right ASCII byte representation of the algorithm at the beginning of buffer.

private static String getAlgorithm(byte[] buffer){ for(int i = 0 ; i < buffer.length ; i ++){ if( buffer[i] == 0x00){ return new String(Arrays.copyOf(buffer,i),StandardCharsets.UTF_8); } } throw new IllegalArgumentException("key does not contain algorithm specification"); }

After changing keyPair.getPair().getPublic().getEncoded() to just keyPair.getPublic() things seemed to work better for me.

cwash added a commit to cwash/License3j that referenced this issue Jan 15, 2019
verhas added a commit that referenced this issue Jan 15, 2019
#47 - Bytes output from digest command do not include algorithm
@verhas
Copy link
Owner

verhas commented Jan 15, 2019

Pull request accepted, merged.

@verhas verhas closed this as completed Jan 15, 2019
klenkes74 added a commit to klenkes74/License3j that referenced this issue Aug 3, 2020
* Building site for 1.0.4-SNAPSHOT

* Building site for 1.0.4

* Building site for 1.0.5-SNAPSHOT

* Building site for 1.0.5-SNAPSHOT

* Building site for 1.0.5-SNAPSHOT

* Building site for 1.0.5-SNAPSHOT

* Building site for 1.0.5-SNAPSHOT

* more java code cleanup

* test was fixed signaling false positive error
license is loaded prom properties to String using "\n" even on Windows from now on

* package name was added to javadoc and to usage printout since License3j is no longer in the default package

* package name was added to javadoc and to usage printout since License3j is no longer in the default package

* The main class moved from the default package into package com.javax0.license3j

* documentation moved to Wiki
travis build modified
mvn compiler plugin also modified to 3.7.0

* source level changed to 1.9

* tests are fixed and made stable

* mvn build debug -X in travis

* wrong merging fixed

* build trigger

* build trigger

* license file was added

* package info is not needed since we do not have any classes in the
default package
methods that were not used in SourceLine were deleted and another
one that was used but did not exist due to some merge error/mistake
javadoc was commented out from the build becuase of some version
incompatibility that I could not overcome

* travis script upgrade to install oraclejdk10

* variable types changed to var wherever possible

* Update InterfaceSelector.java

allowed check doesn't work because if the list is not empty, the interface is always validated

* InterfaceSelector tests

* tests are converted to JUNIT 5

* commented part deleted

* version set to 2.0.0

* version set to 2.0.0-SNAPSHOT

* javadoc updated

* SNAPSNOT

* 2.0.0 release version

* project URL added

* changed to openjdk

* travis update

* first files for the release 3.0.0

* Feature test got full coverage

* Feature to and from string conversion

* analysis things fixed

* license serialization start

* license deserialization

* license to string

* license save and restore, some electronic signature code

* more development

* command line options started to implement

* license signing and verifying moved to license
license signature gets into predefined feature

* repl reworked
key load does not work
feature text format default type is STRING
date format HH:mm:ss.SSS is optional from right to left

* key files contain the algorithm at the start zero char terminated

* bug fixed reading text format license
pom font encoding and plugin versions

* repl executing .license3j startup file
repl implements . file to execute external file
dig to dump key digest to screen
dump to show license content

* documentation was added and also UUID as a new feature, but no tests
so far

* UUID tests were added
UUID features were added
revocation features in separate class
Bouncy Castle dependency removed

* com.javax0 packages moved to javax0

* code rearrangements

* eliminated the package 'three'

* project version upgraded to 3.0.0-SNAPSHOT

* pom file modified to contain groupId and artifactId
code modification
documentation readme.md

* cleanup

* cleanup

* readme.md was proofread using grammarly

* links to outdated documentation removed

* testSignature failed randonly every 256 times once

* Repl signign license checks that there is a license and avoid NPE
documentation of Repl started

* key loading uses the last argument as the name of the key file and
does not require that you write 'keyFile=' at the end of the line

* regular expression is no longer used in repl
aliases can be defined in repl

* verhas#47 - Bytes output from digest command do not include algorithm

* documentation was extended for the Repl

* release 3.0.0

* next snapshot version 3.0.1-SNAPSHOT

* Repl application was removed

* mockito version upgraded

* surefire version updated for Junit5
now that tests run a test failed
code fixed
some tests also fixed to follow license test exctraction change

* release creating shell script

* full cypher transformation is stored in the keys

* License now really saves the full cypher string in the keys

* cypher -> cipher
cipher can be queried

* JavaDoc was extended

* analysis changes

* javadoc added

* javadoc added

* Update readme.md

Fix wrong command

Use dumpPublicKey instead of digestPublicKey

* typo fixed

* typo fixed

* readme formatting

* readme formatting

* documentation updated with picture

* documentation updated with picture

* documentation updated with picture

* documentation updated with picture

* documentation updated with picture

* documentation updated with picture

* documentation updated with picture

* documentation updated with picture

* documentation updated with picture

* documentation updated with picture

* documentation updated with picture

* bug fixes, new tests and documentation

* license reading can be size limited

* bugs fixed

* doc updated

* typo fixed

* repl was corrected it is not part of the license3j any more

* documentation

* release 3.1.0

* version upgraded to 3.1.0 in readme

* release 3.1.1
time zone bug fixed
network interface test is stable

* readme updated

* version 3.1.2

* 3.1.3-SNAPSHOT

* updated to use jbel to generate Java 8 code

* updated to use jbel to generate Java 8 code

* version 3.1.3

* 3.1.4-SNAPSHOT release version jump
documentation fix
getFeatures uses TreeMap

* java::Geci dependency added and used in Feature.java

* broken

* using iterate at as many places as possible

* Fix confusion between Cipher and Algorithm

* typo fixed

* POM to 3.1.4 release

* POM to 3.1.4 release + fix template

* POM to 3.1.5.-SNAPSHOT

* javadoc typo fix

* test formatting

* Fix exception message

* Add developer credentials

* issue 66 bug was fixed
now you can have Strign feature that contains ':' in it

* new unit tests to cover license file reading and file writing

* formatting, import optimization

* test files are deleted after they were created and checked

* modified travis file

* modified travis file

* typos fixed, tests are added to increase the coverage
cleanup of the code

* Feature throws NPE for null argument and not IllegalArgumentException

* documentation language updated

* version upped to release 3.1.5

* version upped to 3.1.6-SNAPSHOT

* logo was added

* closing is checked with AtomicBoolean instead of normal boolean

JavaDoc was extended

* verhas#68 Reduce Stream terminal operations and other code improvements

* jdocify name was corrected

* Java 9 API from PR#68 was reverted to Java 8 JDK compatible call so that it still copiles with Jabel

* empty <p> tags from JavaDoc removed

* empty <p> tags from JavaDoc removed

* documentation and code style was updated

Co-authored-by: Peter Verhas <peter@verhas.com>
Co-authored-by: ZeJ0hn <38920448+ZeJ0hn@users.noreply.github.com>
Co-authored-by: Chris Wash <chris.wash@gmail.com>
Co-authored-by: robert7k <robert7k@users.noreply.github.com>
Co-authored-by: Robert Siebeck <robert@siebeck.org>
Co-authored-by: dkcm <daniel.kuan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants