Decrpyting using pkcs#11 tool - encryption

I'm trying too encrypt and decrypt using pkcs#11-tool
echo 'Hello word !' | openssl pkeyutl -encrypt -pubin \
-inkey pub.pem \
-pkeyopt rsa_padding_mode:oaep \
-pkeyopt rsa_oaep_md:sha512 \
-pkeyopt rsa_mgf1_md:sha512 \
-out encrypted.data
This work find but trying to decrypt it fail
pkcs11-tool --module /usr/local/lib/softhsm/libsofthsm2.so --decrypt \
--mechanism RSA-PKCS-OAEP \
--input-file encrypted.data \
--label keyp \
--hash-algorithm SHA512 --pin Jojo
I'm having this error :
Using slot 0 with a present token (0x607f2e7f)
Using decrypt algorithm RSA-PKCS-OAEP
OAEP parameters: hashAlg=SHA512, mgf=MGF1-SHA512, source_type=0, source_ptr=(nil), source_len=0
error: PKCS11 function C_DecryptInit failed: rv = CKR_ARGUMENTS_BAD (0x7)
Aborting.
I'm following this tutorial : https://docs.nitrokey.com/nethsm/guides/pkcs11_with_pkcs11-tool and can't what wrong.

Related

How to decode openssl enc'd data with salted password?

$ curl -s 'https://finance.yahoo.com/quote/MSFT/profile?p=MSFT' | awk -v ORS= 'match($0, /^ *root[.]App[.]main = (.*);$/, a) { print a[1] }' | jq -r .context.dispatcher.stores > /tmp/tmp.txt
$ file /tmp/tmp.txt
/tmp/tmp.txt: openssl enc'd data with salted password, base64 encoded
How can I decode the above data?

How to decrypt AES encrypted data with openssl command? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 months ago.
Improve this question
I want to decrypt AES encrypted data with openssl command.
Encrypted data: GD5YV2naJZ/x3mQnfictWQ== (base64 encoded)
Key: uHe2MCmggLlugpGBiMVuXTck7OT8Nk8g
Cipher: AES-256-CBC
IV: LNP8U7pc6GjxzxAtgw4s3A== (base64 encoded)
Follow these steps:
$ echo GD5YV2naJZ/x3mQnfictWQ== | openssl base64 -d > data.enc
$ iv=$( echo LNP8U7pc6GjxzxAtgw4s3A== | openssl base64 -d | xxd -p | tr -d '\n' )
$ echo $iv
2cd3fc53ba5ce868f1cf102d830e2cdc
$ key=$( echo uHe2MCmggLlugpGBiMVuXTck7OT8Nk8g | xxd -p | tr -d '\n' )
$ echo $key
754865324d436d67674c6c7567704742694d56755854636b374f54384e6b38670a
$ openssl aes-256-cbc -d -in data.enc -K $key -iv $iv
s:4:"Test";
With -base64 option, the decrypt command can directly use base64 encoded data as the input:
$ echo GD5YV2naJZ/x3mQnfictWQ== | openssl aes-256-cbc -d -base64 -K $key -iv $iv
s:4:"Test";
Please follow the encryption and decryption of the string according to its documentation and follow the step as well:
to decrypt a string use the following:
Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Support\Facades\Crypt;
try {
$decrypted = Crypt::decryptString($encryptedValue);
} catch (DecryptException $e) {
//
}
for encryption use:
use Illuminate\Support\Facades\Crypt;
Crypt::encryptString($request->token)

How to decrypt a large AES encrypted data with openssl command?

I want to decrypt large AES encrypted data:
Encrypted data: 7dS560FiDJvUji7c+ky/9nQp+HwK3SEOkY4zefqlFuEyF2/vevrv8K4GJNr2zxD7+j28RK97LmaHjwY9F+/feO6T2DAQuJQsT3wp/fKCPyErwZggsE+ufzvEJZK/XObR8CdbBe8EGZC//JsuMo7MV6SSe267jp4U2iIz4xIFxUlFVy9QcjTr6AUJZdVogedreBgy3/q/isAqOvwoHuj74MV5gkfaXWvmqESjMF4s5wMsYmS1WuBWOR6rw+TSwuL52CiVC5arHuJJEKuodO58bJ+1Ip9uelUIOETswiZmZB6gpTkbos7ij0BpJregejT+9vsDO1tB7+QpByMqeeEbEiSp4N833Z29WmVmy+HpxdZvOPIJ2pyelVhRVPPs/V7VREs4v8/e3X1jR0saA1sSyKYNgIGZUWaQTJwBNi87IPkGiUtyhPnrrKh+BighshJi+Jd+s3+sTYM5CaADvaGhm3wx96rBQi2So+NmFcm5cQa4jRA4S8sLGHmniUO0iiEcxQ2FvlGt+0PBqdbCPewBgOHdjpBUYjs1oR4pV5VjbjTfuIh75G7TS6TZT/gMewJXOXPw88zsSgjXVjRK0obOXaJBKABJ8AqKbKULWHoeMuWW4OdiSZ7mNVt6N40LK/u12vpqWU7Wt5XbSeE3arJPjljEV7WhafKvIOHFx+cK0wB9LQnFUrx/FTLL5HDDEkhnVkm02vxXSFKDwP36VgQnPpvOnY5fbJUTyjnwJcO8I9/H1hYwzPRhos2eNAdHZ3aMysU8zSobwUVto9GnQrvVmVURFyEX6fwifkrf2DTfCsDNSsHt4DLCtsszABKTwTezUoBesNkndk/Qkcd13GEZjTHoyP2tLp85nYwbwI6P+yr1jeu9v3ocN5p0LWPXdwlyTo55WeYkGzlJLsM6d9sut1qlcyQ2AZ536+eYFAIURJkmSexwfbdRebwckvqURRO3a55WCbLxVARKDHnyfculr/ndwyZF7J0RX4G1KcwSgfRdnBpUCkpGeQRImv5Ry5RYXwp5XfKQDrGTCEhV3XtDBD4b2eTxw4KwgJUq9T6IQjNNyPyDwM5AFxS2Y+4wAA0PA2iADfVe3kZrOKYpZvVn0Q== (base64 encoded)
Key: uHe2MCmggLlugpGBiMVuXTck7OT8Nk8g (base64 encoded)
Cipher: AES-256-CBC
IV: LNP8U7pc6GjxzxAtgw4s3A== (base64 encoded)
I try to use this command for it:
openssl aes-256-cbc -d -in data.enc -out data.dec -K $key -iv $iv
In $key and $iv i decoded from encoded values this way
iv=$( cat response.json | jq .iv -r | openssl base64 -d | xxd -p | tr -d '\n' )
But i have crashed data like this
^GÌ<8a>û)F"PEi~^K±jÔ^AcWSM
23NDwSOqovXSFGNfy3WatkCreYRd7kcWSM";

awscli doesn't consider global-secondary-indexes when validating attribute-definitions

I'm trying to initialize dynamodb table when creating a localstack container.
Consider following command:
awslocal dynamodb create-table \
--debug \
--table-name Journal \
--global-secondary-indexes 'IndexName=GetJournalRowsIndex, KeySchema=[{AttributeName=persistence-id, KeyType=HASH},{AttributeName=sequence-nr,KeyType=RANGE}], Projection={ProjectionType=ALL}, ProvisionedThroughput={ReadCapacityUnits=10,WriteCapacityUnits=10}' \
--global-secondary-indexes 'IndexName=TagsIndex, KeySchema=[{AttributeName=tags,KeyType=HASH}],Projection={ProjectionType=ALL},ProvisionedThroughput={ReadCapacityUnits=10,WriteCapacityUnits=10}' \
--key-schema \
AttributeName=pkey,KeyType=HASH \
AttributeName=skey,KeyType=RANGE \
--attribute-definitions \
AttributeName=persistence-id,AttributeType=S \
AttributeName=pkey,AttributeType=S \
AttributeName=skey,AttributeType=S \
AttributeName=sequence-nr,AttributeType=N \
AttributeName=tags,AttributeType=S \
--billing-mode PAY_PER_REQUEST
I'm getting the following error:
An error occurred (ValidationException) when calling the CreateTable operation: The number of attributes in key schema must match the number of attributesdefined in attribute definitions.
I'm using those in GSI so I wonder what am I doing wrong here?
I guess you can't specify global-secondary-indexes flag twice. Try the following
awslocal dynamodb create-table \
--debug \
--table-name Journal \
--global-secondary-indexes "[{\"IndexName\": \"GetJournalRowsIndex\", \"KeySchema\": [{\"AttributeName\": \"persistence-id\", \"KeyType\": \"HASH\"}, {\"AttributeName\": \"sequence-nr\", \"KeyType\": \"RANGE\"}], \"Projection\": {\"ProjectionType\": \"ALL\"}, \"ProvisionedThroughput\": {\"ReadCapacityUnits\": 1, \"WriteCapacityUnits\": 1}}, {\"IndexName\": \"TagsIndex\", \"KeySchema\": [{\"AttributeName\": \"tags\", \"KeyType\": \"HASH\"}], \"Projection\": {\"ProjectionType\": \"ALL\"}, \"ProvisionedThroughput\": {\"ReadCapacityUnits\": 1, \"WriteCapacityUnits\": 1}}]" \
--key-schema \
AttributeName=pkey,KeyType=HASH \
AttributeName=skey,KeyType=RANGE \
--attribute-definitions \
AttributeName=persistence-id,AttributeType=S \
AttributeName=pkey,AttributeType=S \
AttributeName=skey,AttributeType=S \
AttributeName=sequence-nr,AttributeType=N \
AttributeName=tags,AttributeType=S \
--billing-mode PAY_PER_REQUEST

Nginx 1.7.9 with google pagespeed plugin giving error

I want to install nginx 1.7.9 with nginx pagespeed latest version.
my environment is Ubuntu 14.04.1 LTS trusty nginx 1.7.9 page speed 1.9.32.2
config command was successful
./configure --add-module=/usr/local/nginx/modules/ngx_pagespeed-1.9.32.2-beta --prefix=/usr/local/nginx --sbin-path=/usr/local/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx
for config : i am getting following output
checking for zlib library ... found
creating objs/Makefile
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using builtin md5 code
+ sha1 library is not found
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/sbin/nginx"
nginx configuration prefix: "/etc/nginx"
nginx configuration file: "/etc/nginx/nginx.conf"
nginx pid file: "/run/nginx.pid"
nginx error log file: "/var/log/nginx/error.log"
nginx http access log file: "/var/log/nginx/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
while running make, i am getting following error.
/usr/local/nginx/modules/ngx_pagespeed-1.9.32.2-beta/psol/include/third_party/chromium/src -I /usr/local/nginx/modules/ngx_pagespeed-1.9.32.2-beta/psol/include/third_party/google-sparsehash/src -I /usr/local/nginx/modules/ngx_pagespeed-1.9.32.2-beta/psol/include/third_party/google-sparsehash/gen/arch/linux/x64/include -I /usr/local/nginx/modules/ngx_pagespeed-1.9.32.2-beta/psol/include/third_party/protobuf/src -I /usr/local/nginx/modules/ngx_pagespeed-1.9.32.2-beta/psol/include/third_party/re2/src -I /usr/local/nginx/modules/ngx_pagespeed-1.9.32.2-beta/psol/include/out/Release/obj/gen -I /usr/local/nginx/modules/ngx_pagespeed-1.9.32.2-beta/psol/include/out/Release/obj/gen/protoc_out/instaweb -I /usr/local/nginx/modules/ngx_pagespeed-1.9.32.2-beta/psol/include/third_party/apr/src/include -I /usr/local/nginx/modules/ngx_pagespeed-1.9.32.2-beta/psol/include/third_party/aprutil/src/include -I /usr/local/nginx/modules/ngx_pagespeed-1.9.32.2-beta/psol/include/third_party/apr/gen/arch/linux/x64/include -I /usr/local/nginx/modules/ngx_pagespeed-1.9.32.2-beta/psol/include/third_party/aprutil/gen/arch/linux/x64/include -I objs \
-o objs/ngx_modules.o \
objs/ngx_modules.c
cc -o objs/nginx \
objs/src/core/nginx.o \
objs/src/core/ngx_log.o \
objs/src/core/ngx_palloc.o \
objs/src/core/ngx_array.o \
objs/src/core/ngx_list.o \
objs/src/core/ngx_hash.o \
objs/src/core/ngx_buf.o \
objs/src/core/ngx_queue.o \
objs/src/core/ngx_output_chain.o \
objs/src/core/ngx_string.o \
objs/src/core/ngx_parse.o \
objs/src/core/ngx_inet.o \
objs/src/core/ngx_file.o \
objs/src/core/ngx_crc32.o \
objs/src/core/ngx_murmurhash.o \
objs/src/core/ngx_md5.o \
objs/src/core/ngx_rbtree.o \
objs/src/core/ngx_radix_tree.o \
objs/src/core/ngx_slab.o \
objs/src/core/ngx_times.o \
objs/src/core/ngx_shmtx.o \
objs/src/core/ngx_connection.o \
objs/src/core/ngx_cycle.o \
objs/src/core/ngx_spinlock.o \
objs/src/core/ngx_cpuinfo.o \
objs/src/core/ngx_conf_file.o \
objs/src/core/ngx_resolver.o \
objs/src/core/ngx_open_file_cache.o \
objs/src/core/ngx_crypt.o \
objs/src/core/ngx_proxy_protocol.o \
objs/src/core/ngx_syslog.o \
objs/src/event/ngx_event.o \
objs/src/event/ngx_event_timer.o \
objs/src/event/ngx_event_posted.o \
objs/src/event/ngx_event_busy_lock.o \
objs/src/event/ngx_event_accept.o \
objs/src/event/ngx_event_connect.o \
objs/src/event/ngx_event_pipe.o \
objs/src/os/unix/ngx_time.o \
objs/src/os/unix/ngx_errno.o \
objs/src/os/unix/ngx_alloc.o \
objs/src/os/unix/ngx_files.o \
objs/src/os/unix/ngx_socket.o \
objs/src/os/unix/ngx_recv.o \
objs/src/os/unix/ngx_readv_chain.o \
objs/src/os/unix/ngx_udp_recv.o \
objs/src/os/unix/ngx_send.o \
objs/src/os/unix/ngx_writev_chain.o \
objs/src/os/unix/ngx_channel.o \
objs/src/os/unix/ngx_shmem.o \
objs/src/os/unix/ngx_process.o \
objs/src/os/unix/ngx_daemon.o \
objs/src/os/unix/ngx_setaffinity.o \
objs/src/os/unix/ngx_setproctitle.o \
objs/src/os/unix/ngx_posix_init.o \
objs/src/os/unix/ngx_user.o \
objs/src/os/unix/ngx_process_cycle.o \
objs/src/os/unix/ngx_linux_init.o \
objs/src/event/modules/ngx_epoll_module.o \
objs/src/os/unix/ngx_linux_sendfile_chain.o \
objs/src/core/ngx_regex.o \
objs/src/http/ngx_http.o \
objs/src/http/ngx_http_core_module.o \
objs/src/http/ngx_http_special_response.o \
objs/src/http/ngx_http_request.o \
objs/src/http/ngx_http_parse.o \
objs/src/http/ngx_http_header_filter_module.o \
objs/src/http/ngx_http_write_filter_module.o \
objs/src/http/ngx_http_copy_filter_module.o \
objs/src/http/modules/ngx_http_log_module.o \
objs/src/http/ngx_http_request_body.o \
objs/src/http/ngx_http_variables.o \
objs/src/http/ngx_http_script.o \
objs/src/http/ngx_http_upstream.o \
objs/src/http/ngx_http_upstream_round_robin.o \
objs/src/http/ngx_http_parse_time.o \
objs/src/http/modules/ngx_http_static_module.o \
objs/src/http/modules/ngx_http_index_module.o \
objs/src/http/modules/ngx_http_chunked_filter_module.o \
objs/src/http/modules/ngx_http_range_filter_module.o \
objs/src/http/modules/ngx_http_headers_filter_module.o \
objs/src/http/modules/ngx_http_not_modified_filter_module.o \
objs/src/http/ngx_http_busy_lock.o \
objs/src/http/ngx_http_file_cache.o \
objs/src/http/modules/ngx_http_gzip_filter_module.o \
objs/src/http/ngx_http_postpone_filter_module.o \
objs/src/http/modules/ngx_http_ssi_filter_module.o \
objs/src/http/modules/ngx_http_charset_filter_module.o \
objs/src/http/modules/ngx_http_userid_filter_module.o \
objs/src/http/modules/ngx_http_autoindex_module.o \
objs/src/http/modules/ngx_http_auth_basic_module.o \
objs/src/http/modules/ngx_http_access_module.o \
objs/src/http/modules/ngx_http_limit_conn_module.o \
objs/src/http/modules/ngx_http_limit_req_module.o \
objs/src/http/modules/ngx_http_geo_module.o \
objs/src/http/modules/ngx_http_map_module.o \
objs/src/http/modules/ngx_http_split_clients_module.o \
objs/src/http/modules/ngx_http_referer_module.o \
objs/src/http/modules/ngx_http_rewrite_module.o \
objs/src/http/modules/ngx_http_proxy_module.o \
objs/src/http/modules/ngx_http_fastcgi_module.o \
objs/src/http/modules/ngx_http_uwsgi_module.o \
objs/src/http/modules/ngx_http_scgi_module.o \
objs/src/http/modules/ngx_http_memcached_module.o \
objs/src/http/modules/ngx_http_empty_gif_module.o \
objs/src/http/modules/ngx_http_browser_module.o \
objs/src/http/modules/ngx_http_upstream_hash_module.o \
objs/src/http/modules/ngx_http_upstream_ip_hash_module.o \
objs/src/http/modules/ngx_http_upstream_least_conn_module.o \
objs/src/http/modules/ngx_http_upstream_keepalive_module.o \
objs/addon/src/log_message_handler.o \
objs/addon/src/ngx_base_fetch.o \
objs/addon/src/ngx_caching_headers.o \
objs/addon/src/ngx_fetch.o \
objs/addon/src/ngx_gzip_setter.o \
objs/addon/src/ngx_list_iterator.o \
objs/addon/src/ngx_message_handler.o \
objs/addon/src/ngx_pagespeed.o \
objs/addon/src/ngx_rewrite_driver_factory.o \
objs/addon/src/ngx_rewrite_options.o \
objs/addon/src/ngx_server_context.o \
objs/addon/src/ngx_url_async_fetcher.o \
objs/ngx_modules.o \
-lpthread -lcrypt -lstdc++ /usr/local/nginx/modules/ngx_pagespeed-1.9.32.2-beta/psol/lib/Release/linux/x64/pagespeed_automatic.a -lrt -pthread -lm -lpcre -lz
make[1]: Leaving directory `/data/nginx-1.7.9'
make -f objs/Makefile manpage
make[1]: Entering directory `/data/nginx-1.7.9'
sed -e "s|%%PREFIX%%|/usr/local/nginx|" \
-e "s|%%PID_PATH%%|/run/nginx.pid|" \
-e "s|%%CONF_PATH%%|/etc/nginx/nginx.conf|" \
-e "s|%%ERROR_LOG_PATH%%|/var/log/nginx/error.log|" \
< man/nginx.8 > objs/nginx.8
make[1]: Leaving directory `/data/nginx-1.7.9'
can any help in getting this issue fixed ? i dont know what exactly this error is ?
This was fixed . I just updated config before make

Resources