1
1
/*
2
- * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
2
+ * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
3
3
*
4
4
* Licensed under the OpenSSL license (the "License"). You may not use
5
5
* this file except in compliance with the License. You can obtain a copy
@@ -300,9 +300,13 @@ int password_callback(char *buf, int bufsiz, int verify, PW_CB_DATA *cb_tmp)
300
300
int ui_flags = 0 ;
301
301
const char * prompt_info = NULL ;
302
302
char * prompt ;
303
+ int pw_min_len = PW_MIN_LENGTH ;
303
304
304
305
if (cb_data != NULL && cb_data -> prompt_info != NULL )
305
306
prompt_info = cb_data -> prompt_info ;
307
+ if (cb_data != NULL && cb_data -> password != NULL
308
+ && * (const char * )cb_data -> password != '\0' )
309
+ pw_min_len = 1 ;
306
310
prompt = UI_construct_prompt (ui , "pass phrase" , prompt_info );
307
311
if (!prompt ) {
308
312
BIO_printf (bio_err , "Out of memory\n" );
@@ -317,12 +321,12 @@ int password_callback(char *buf, int bufsiz, int verify, PW_CB_DATA *cb_tmp)
317
321
(void )UI_add_user_data (ui , cb_data );
318
322
319
323
ok = UI_add_input_string (ui , prompt , ui_flags , buf ,
320
- PW_MIN_LENGTH , bufsiz - 1 );
324
+ pw_min_len , bufsiz - 1 );
321
325
322
326
if (ok >= 0 && verify ) {
323
327
buff = app_malloc (bufsiz , "password buffer" );
324
328
ok = UI_add_verify_string (ui , prompt , ui_flags , buff ,
325
- PW_MIN_LENGTH , bufsiz - 1 , buf );
329
+ pw_min_len , bufsiz - 1 , buf );
326
330
}
327
331
if (ok >= 0 )
328
332
do {
0 commit comments