11/*
2- * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
2+ * Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
33 *
44 * Licensed under the OpenSSL license (the "License"). You may not use
55 * 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)
300300 int ui_flags = 0 ;
301301 const char * prompt_info = NULL ;
302302 char * prompt ;
303+ int pw_min_len = PW_MIN_LENGTH ;
303304
304305 if (cb_data != NULL && cb_data -> prompt_info != NULL )
305306 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 ;
306310 prompt = UI_construct_prompt (ui , "pass phrase" , prompt_info );
307311 if (!prompt ) {
308312 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)
317321 (void )UI_add_user_data (ui , cb_data );
318322
319323 ok = UI_add_input_string (ui , prompt , ui_flags , buf ,
320- PW_MIN_LENGTH , bufsiz - 1 );
324+ pw_min_len , bufsiz - 1 );
321325
322326 if (ok >= 0 && verify ) {
323327 buff = app_malloc (bufsiz , "password buffer" );
324328 ok = UI_add_verify_string (ui , prompt , ui_flags , buff ,
325- PW_MIN_LENGTH , bufsiz - 1 , buf );
329+ pw_min_len , bufsiz - 1 , buf );
326330 }
327331 if (ok >= 0 )
328332 do {
0 commit comments