Latest update.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -63,8 +63,12 @@ IF[{- !$disabled{des} -}]
|
||||
cipher_tdes_default.c cipher_tdes_default_hw.c \
|
||||
cipher_tdes_wrap.c cipher_tdes_wrap_hw.c
|
||||
SOURCE[$DES_GOAL]=\
|
||||
cipher_desx.c cipher_desx_hw.c cipher_tdes_common.c\
|
||||
cipher_desx.c cipher_desx_hw.c \
|
||||
cipher_des.c cipher_des_hw.c
|
||||
IF[{- !$disabled{module} -}]
|
||||
SOURCE[$DES_GOAL]=\
|
||||
cipher_tdes_common.c
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
IF[{- !$disabled{aria} -}]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2011-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2011-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2001-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2001-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -15,8 +15,20 @@ ENDIF
|
||||
IF[{- !$disabled{ec} -}]
|
||||
SOURCE[$EC_GOAL]=ec_kmgmt.c
|
||||
ENDIF
|
||||
|
||||
IF[{- !$disabled{asm} -}]
|
||||
$ECDEF_s390x=S390X_EC_ASM
|
||||
|
||||
# Now that we have defined all the arch specific variables, use the
|
||||
# appropriate one, and define the appropriate macros
|
||||
IF[$ECASM_{- $target{asm_arch} -}]
|
||||
$ECDEF=$ECDEF_{- $target{asm_arch} -}
|
||||
ENDIF
|
||||
ENDIF
|
||||
|
||||
IF[{- !$disabled{ec} -}]
|
||||
SOURCE[$ECX_GOAL]=ecx_kmgmt.c
|
||||
DEFINE[$ECX_GOAL]=$ECDEF
|
||||
ENDIF
|
||||
|
||||
SOURCE[../../libfips.a]=rsa_kmgmt.c
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -13,19 +13,27 @@
|
||||
*/
|
||||
#include "internal/deprecated.h"
|
||||
|
||||
#include <string.h> /* strcmp */
|
||||
#include <openssl/core_numbers.h>
|
||||
#include <openssl/core_names.h>
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/dh.h>
|
||||
#include <openssl/params.h>
|
||||
#include <openssl/err.h>
|
||||
#include "prov/implementations.h"
|
||||
#include "prov/providercommon.h"
|
||||
#include "prov/provider_ctx.h"
|
||||
#include "crypto/dh.h"
|
||||
#include "openssl/param_build.h"
|
||||
#include "internal/sizes.h"
|
||||
#include "internal/nelem.h"
|
||||
#include "internal/param_build_set.h"
|
||||
|
||||
static OSSL_OP_keymgmt_new_fn dh_newdata;
|
||||
static OSSL_OP_keymgmt_free_fn dh_freedata;
|
||||
static OSSL_OP_keymgmt_gen_init_fn dh_gen_init;
|
||||
static OSSL_OP_keymgmt_gen_set_template_fn dh_gen_set_template;
|
||||
static OSSL_OP_keymgmt_gen_set_params_fn dh_gen_set_params;
|
||||
static OSSL_OP_keymgmt_gen_settable_params_fn dh_gen_settable_params;
|
||||
static OSSL_OP_keymgmt_gen_fn dh_gen;
|
||||
static OSSL_OP_keymgmt_gen_cleanup_fn dh_gen_cleanup;
|
||||
static OSSL_OP_keymgmt_get_params_fn dh_get_params;
|
||||
static OSSL_OP_keymgmt_gettable_params_fn dh_gettable_params;
|
||||
static OSSL_OP_keymgmt_has_fn dh_has;
|
||||
@@ -36,42 +44,82 @@ static OSSL_OP_keymgmt_import_types_fn dh_import_types;
|
||||
static OSSL_OP_keymgmt_export_fn dh_export;
|
||||
static OSSL_OP_keymgmt_export_types_fn dh_export_types;
|
||||
|
||||
#define DH_POSSIBLE_SELECTIONS \
|
||||
#define DH_POSSIBLE_SELECTIONS \
|
||||
(OSSL_KEYMGMT_SELECT_KEYPAIR | OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS)
|
||||
|
||||
static int domparams_to_params(DH *dh, OSSL_PARAM_BLD *tmpl)
|
||||
struct dh_gen_ctx {
|
||||
OPENSSL_CTX *libctx;
|
||||
|
||||
FFC_PARAMS *ffc_params;
|
||||
int selection;
|
||||
/* All these parameters are used for parameter generation only */
|
||||
/* If there is a group name then the remaining parameters are not needed */
|
||||
int group_nid;
|
||||
size_t pbits;
|
||||
size_t qbits;
|
||||
EVP_MD *md;
|
||||
unsigned char *seed; /* optional FIPS186-4 param for testing */
|
||||
size_t seedlen;
|
||||
int gindex; /* optional FIPS186-4 generator index (ignored if -1) */
|
||||
int gen_type; /* see dhtype2id */
|
||||
int generator; /* Used by DH_PARAMGEN_TYPE_GENERATOR in non fips mode only */
|
||||
int pcounter;
|
||||
int hindex;
|
||||
int priv_len;
|
||||
|
||||
OSSL_CALLBACK *cb;
|
||||
void *cbarg;
|
||||
};
|
||||
|
||||
typedef struct dh_name2id_st{
|
||||
const char *name;
|
||||
int id;
|
||||
} DH_GENTYPE_NAME2ID;
|
||||
|
||||
static const DH_GENTYPE_NAME2ID dhtype2id[]=
|
||||
{
|
||||
const BIGNUM *dh_p = NULL, *dh_g = NULL;
|
||||
{ "default", DH_PARAMGEN_TYPE_FIPS_186_4 },
|
||||
{ "fips186_4", DH_PARAMGEN_TYPE_FIPS_186_4 },
|
||||
{ "fips186_2", DH_PARAMGEN_TYPE_FIPS_186_2 },
|
||||
{ "group", DH_PARAMGEN_TYPE_GROUP },
|
||||
{ "generator", DH_PARAMGEN_TYPE_GENERATOR }
|
||||
};
|
||||
|
||||
if (dh == NULL)
|
||||
return 0;
|
||||
const char *dh_gen_type_id2name(int id)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
DH_get0_pqg(dh, &dh_p, NULL, &dh_g);
|
||||
if (dh_p != NULL
|
||||
&& !OSSL_PARAM_BLD_push_BN(tmpl, OSSL_PKEY_PARAM_FFC_P, dh_p))
|
||||
return 0;
|
||||
if (dh_g != NULL
|
||||
&& !OSSL_PARAM_BLD_push_BN(tmpl, OSSL_PKEY_PARAM_FFC_G, dh_g))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
for (i = 0; i < OSSL_NELEM(dhtype2id); ++i) {
|
||||
if (dhtype2id[i].id == id)
|
||||
return dhtype2id[i].name;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int key_to_params(DH *dh, OSSL_PARAM_BLD *tmpl)
|
||||
static int dh_gen_type_name2id(const char *name)
|
||||
{
|
||||
const BIGNUM *priv_key = NULL, *pub_key = NULL;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < OSSL_NELEM(dhtype2id); ++i) {
|
||||
if (strcmp(dhtype2id[i].name, name) == 0)
|
||||
return dhtype2id[i].id;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int dh_key_todata(DH *dh, OSSL_PARAM_BLD *bld, OSSL_PARAM params[])
|
||||
{
|
||||
const BIGNUM *priv = NULL, *pub = NULL;
|
||||
|
||||
if (dh == NULL)
|
||||
return 0;
|
||||
if (!domparams_to_params(dh, tmpl))
|
||||
return 0;
|
||||
|
||||
DH_get0_key(dh, &pub_key, &priv_key);
|
||||
if (priv_key != NULL
|
||||
&& !OSSL_PARAM_BLD_push_BN(tmpl, OSSL_PKEY_PARAM_PRIV_KEY, priv_key))
|
||||
DH_get0_key(dh, &pub, &priv);
|
||||
if (priv != NULL
|
||||
&& !ossl_param_build_set_bn(bld, params, OSSL_PKEY_PARAM_PRIV_KEY, priv))
|
||||
return 0;
|
||||
if (pub_key != NULL
|
||||
&& !OSSL_PARAM_BLD_push_BN(tmpl, OSSL_PKEY_PARAM_PUB_KEY, pub_key))
|
||||
if (pub != NULL
|
||||
&& !ossl_param_build_set_bn(bld, params, OSSL_PKEY_PARAM_PUB_KEY, pub))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
@@ -79,7 +127,7 @@ static int key_to_params(DH *dh, OSSL_PARAM_BLD *tmpl)
|
||||
|
||||
static void *dh_newdata(void *provctx)
|
||||
{
|
||||
return dh_new_with_ctx(PROV_LIBRARY_CONTEXT_OF(provctx));
|
||||
return dh_new_with_libctx(PROV_LIBRARY_CONTEXT_OF(provctx));
|
||||
}
|
||||
|
||||
static void dh_freedata(void *keydata)
|
||||
@@ -128,16 +176,17 @@ static int dh_match(const void *keydata1, const void *keydata2, int selection)
|
||||
static int dh_import(void *keydata, int selection, const OSSL_PARAM params[])
|
||||
{
|
||||
DH *dh = keydata;
|
||||
int ok = 0;
|
||||
int ok = 1;
|
||||
|
||||
if (dh == NULL)
|
||||
return 0;
|
||||
|
||||
if ((selection & DH_POSSIBLE_SELECTIONS) != 0)
|
||||
ok = 1;
|
||||
if ((selection & DH_POSSIBLE_SELECTIONS) == 0)
|
||||
return 0;
|
||||
|
||||
if ((selection & OSSL_KEYMGMT_SELECT_ALL_PARAMETERS) != 0)
|
||||
ok = ok && ffc_fromdata(dh_get0_params(dh), params);
|
||||
ok = ok && dh_ffc_params_fromdata(dh, params);
|
||||
|
||||
if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0)
|
||||
ok = ok && dh_key_fromdata(dh, params);
|
||||
|
||||
@@ -148,7 +197,7 @@ static int dh_export(void *keydata, int selection, OSSL_CALLBACK *param_cb,
|
||||
void *cbarg)
|
||||
{
|
||||
DH *dh = keydata;
|
||||
OSSL_PARAM_BLD *tmpl;
|
||||
OSSL_PARAM_BLD *tmpl = NULL;
|
||||
OSSL_PARAM *params = NULL;
|
||||
int ok = 1;
|
||||
|
||||
@@ -160,30 +209,37 @@ static int dh_export(void *keydata, int selection, OSSL_CALLBACK *param_cb,
|
||||
return 0;
|
||||
|
||||
if ((selection & OSSL_KEYMGMT_SELECT_ALL_PARAMETERS) != 0)
|
||||
ok = ok && domparams_to_params(dh, tmpl);
|
||||
ok = ok && ffc_params_todata(dh_get0_params(dh), tmpl, NULL);
|
||||
if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0)
|
||||
ok = ok && key_to_params(dh, tmpl);
|
||||
ok = ok && dh_key_todata(dh, tmpl, NULL);
|
||||
|
||||
if (!ok
|
||||
|| (params = OSSL_PARAM_BLD_to_param(tmpl)) == NULL) {
|
||||
OSSL_PARAM_BLD_free(tmpl);
|
||||
return 0;
|
||||
ok = 0;
|
||||
goto err;
|
||||
}
|
||||
OSSL_PARAM_BLD_free(tmpl);
|
||||
|
||||
ok = param_cb(params, cbarg);
|
||||
OSSL_PARAM_BLD_free_params(params);
|
||||
err:
|
||||
OSSL_PARAM_BLD_free(tmpl);
|
||||
return ok;
|
||||
}
|
||||
|
||||
/* IMEXPORT = IMPORT + EXPORT */
|
||||
|
||||
# define DH_IMEXPORTABLE_PARAMETERS \
|
||||
OSSL_PARAM_BN(OSSL_PKEY_PARAM_FFC_P, NULL, 0), \
|
||||
OSSL_PARAM_BN(OSSL_PKEY_PARAM_FFC_G, NULL, 0)
|
||||
# define DH_IMEXPORTABLE_PUBLIC_KEY \
|
||||
# define DH_IMEXPORTABLE_PARAMETERS \
|
||||
OSSL_PARAM_BN(OSSL_PKEY_PARAM_FFC_P, NULL, 0), \
|
||||
OSSL_PARAM_BN(OSSL_PKEY_PARAM_FFC_Q, NULL, 0), \
|
||||
OSSL_PARAM_BN(OSSL_PKEY_PARAM_FFC_G, NULL, 0), \
|
||||
OSSL_PARAM_BN(OSSL_PKEY_PARAM_FFC_COFACTOR, NULL, 0), \
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_FFC_GINDEX, NULL), \
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_FFC_PCOUNTER, NULL), \
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_FFC_H, NULL), \
|
||||
OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_FFC_GROUP, NULL, 0), \
|
||||
OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_FFC_SEED, NULL, 0)
|
||||
# define DH_IMEXPORTABLE_PUBLIC_KEY \
|
||||
OSSL_PARAM_BN(OSSL_PKEY_PARAM_PUB_KEY, NULL, 0)
|
||||
# define DH_IMEXPORTABLE_PRIVATE_KEY \
|
||||
# define DH_IMEXPORTABLE_PRIVATE_KEY \
|
||||
OSSL_PARAM_BN(OSSL_PKEY_PARAM_PRIV_KEY, NULL, 0)
|
||||
static const OSSL_PARAM dh_all_types[] = {
|
||||
DH_IMEXPORTABLE_PARAMETERS,
|
||||
@@ -242,13 +298,17 @@ static ossl_inline int dh_get_params(void *key, OSSL_PARAM params[])
|
||||
if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_MAX_SIZE)) != NULL
|
||||
&& !OSSL_PARAM_set_int(p, DH_size(dh)))
|
||||
return 0;
|
||||
return 1;
|
||||
return ffc_params_todata(dh_get0_params(dh), NULL, params)
|
||||
&& dh_key_todata(dh, NULL, params);
|
||||
}
|
||||
|
||||
static const OSSL_PARAM dh_params[] = {
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_BITS, NULL),
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_SECURITY_BITS, NULL),
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_MAX_SIZE, NULL),
|
||||
DH_IMEXPORTABLE_PARAMETERS,
|
||||
DH_IMEXPORTABLE_PUBLIC_KEY,
|
||||
DH_IMEXPORTABLE_PRIVATE_KEY,
|
||||
OSSL_PARAM_END
|
||||
};
|
||||
|
||||
@@ -297,8 +357,263 @@ static int dh_validate(void *keydata, int selection)
|
||||
return ok;
|
||||
}
|
||||
|
||||
static void *dh_gen_init(void *provctx, int selection)
|
||||
{
|
||||
OPENSSL_CTX *libctx = PROV_LIBRARY_CONTEXT_OF(provctx);
|
||||
struct dh_gen_ctx *gctx = NULL;
|
||||
|
||||
if ((selection & (OSSL_KEYMGMT_SELECT_KEYPAIR
|
||||
| OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS)) == 0)
|
||||
return NULL;
|
||||
|
||||
if ((gctx = OPENSSL_zalloc(sizeof(*gctx))) != NULL) {
|
||||
gctx->selection = selection;
|
||||
gctx->libctx = libctx;
|
||||
gctx->pbits = 2048;
|
||||
gctx->qbits = 224;
|
||||
gctx->md = NULL;
|
||||
gctx->gen_type = DH_PARAMGEN_TYPE_FIPS_186_4;
|
||||
gctx->gindex = -1;
|
||||
gctx->hindex = 0;
|
||||
gctx->pcounter = -1;
|
||||
gctx->generator = DH_GENERATOR_2;
|
||||
}
|
||||
return gctx;
|
||||
}
|
||||
|
||||
static int dh_gen_set_template(void *genctx, void *templ)
|
||||
{
|
||||
struct dh_gen_ctx *gctx = genctx;
|
||||
DH *dh = templ;
|
||||
|
||||
if (gctx == NULL || dh == NULL)
|
||||
return 0;
|
||||
gctx->ffc_params = dh_get0_params(dh);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int dh_set_gen_seed(struct dh_gen_ctx *gctx, unsigned char *seed,
|
||||
size_t seedlen)
|
||||
{
|
||||
OPENSSL_clear_free(gctx->seed, gctx->seedlen);
|
||||
gctx->seed = NULL;
|
||||
gctx->seedlen = 0;
|
||||
if (seed != NULL && seedlen > 0) {
|
||||
gctx->seed = OPENSSL_memdup(seed, seedlen);
|
||||
if (gctx->seed == NULL)
|
||||
return 0;
|
||||
gctx->seedlen = seedlen;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int dh_gen_set_params(void *genctx, const OSSL_PARAM params[])
|
||||
{
|
||||
struct dh_gen_ctx *gctx = genctx;
|
||||
const OSSL_PARAM *p;
|
||||
|
||||
if (gctx == NULL)
|
||||
return 0;
|
||||
|
||||
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_TYPE);
|
||||
if (p != NULL) {
|
||||
if (p->data_type != OSSL_PARAM_UTF8_STRING
|
||||
|| ((gctx->gen_type = dh_gen_type_name2id(p->data)) == -1)) {
|
||||
ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_GROUP);
|
||||
if (p != NULL) {
|
||||
if (p->data_type != OSSL_PARAM_UTF8_STRING
|
||||
|| ((gctx->group_nid = ffc_named_group_to_uid(p->data)) == NID_undef)) {
|
||||
ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
|
||||
return 0;
|
||||
}
|
||||
gctx->gen_type = DH_PARAMGEN_TYPE_GROUP;
|
||||
}
|
||||
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_GENERATOR);
|
||||
if (p != NULL && !OSSL_PARAM_get_int(p, &gctx->generator))
|
||||
return 0;
|
||||
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_GINDEX);
|
||||
if (p != NULL && !OSSL_PARAM_get_int(p, &gctx->gindex))
|
||||
return 0;
|
||||
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_PCOUNTER);
|
||||
if (p != NULL && !OSSL_PARAM_get_int(p, &gctx->pcounter))
|
||||
return 0;
|
||||
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_H);
|
||||
if (p != NULL && !OSSL_PARAM_get_int(p, &gctx->hindex))
|
||||
return 0;
|
||||
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_SEED);
|
||||
if (p != NULL
|
||||
&& (p->data_type != OSSL_PARAM_OCTET_STRING
|
||||
|| !dh_set_gen_seed(gctx, p->data, p->data_size)))
|
||||
return 0;
|
||||
|
||||
if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_PBITS)) != NULL
|
||||
&& !OSSL_PARAM_get_size_t(p, &gctx->pbits))
|
||||
return 0;
|
||||
if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_QBITS)) != NULL
|
||||
&& !OSSL_PARAM_get_size_t(p, &gctx->qbits))
|
||||
return 0;
|
||||
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_DIGEST);
|
||||
if (p != NULL) {
|
||||
const OSSL_PARAM *p1;
|
||||
char mdprops[OSSL_MAX_PROPQUERY_SIZE] = { '\0' };
|
||||
char *str = mdprops;
|
||||
|
||||
if (p->data_type != OSSL_PARAM_UTF8_STRING)
|
||||
return 0;
|
||||
p1 = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_DIGEST_PROPS);
|
||||
if (p1 != NULL
|
||||
&& !OSSL_PARAM_get_utf8_string(p1, &str, sizeof(mdprops)))
|
||||
return 0;
|
||||
EVP_MD_free(gctx->md);
|
||||
gctx->md = EVP_MD_fetch(gctx->libctx, p->data, mdprops);
|
||||
if (gctx->md == NULL)
|
||||
return 0;
|
||||
}
|
||||
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_DH_PRIV_LEN);
|
||||
if (p != NULL && !OSSL_PARAM_get_int(p, &gctx->priv_len))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const OSSL_PARAM *dh_gen_settable_params(void *provctx)
|
||||
{
|
||||
static OSSL_PARAM settable[] = {
|
||||
OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_FFC_GROUP, NULL, 0),
|
||||
OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_FFC_TYPE, NULL, 0),
|
||||
OSSL_PARAM_size_t(OSSL_PKEY_PARAM_FFC_PBITS, NULL),
|
||||
OSSL_PARAM_size_t(OSSL_PKEY_PARAM_FFC_QBITS, NULL),
|
||||
OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_FFC_DIGEST, NULL, 0),
|
||||
OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_FFC_DIGEST_PROPS, NULL, 0),
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_FFC_GINDEX, NULL),
|
||||
OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_FFC_SEED, NULL, 0),
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_FFC_GENERATOR, NULL),
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_FFC_PCOUNTER, NULL),
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_FFC_H, NULL),
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_DH_PRIV_LEN, NULL),
|
||||
OSSL_PARAM_END
|
||||
};
|
||||
return settable;
|
||||
}
|
||||
|
||||
static int dh_gencb(int p, int n, BN_GENCB *cb)
|
||||
{
|
||||
struct dh_gen_ctx *gctx = BN_GENCB_get_arg(cb);
|
||||
OSSL_PARAM params[] = { OSSL_PARAM_END, OSSL_PARAM_END, OSSL_PARAM_END };
|
||||
|
||||
params[0] = OSSL_PARAM_construct_int(OSSL_GEN_PARAM_POTENTIAL, &p);
|
||||
params[1] = OSSL_PARAM_construct_int(OSSL_GEN_PARAM_ITERATION, &n);
|
||||
|
||||
return gctx->cb(params, gctx->cbarg);
|
||||
}
|
||||
|
||||
static void *dh_gen(void *genctx, OSSL_CALLBACK *osslcb, void *cbarg)
|
||||
{
|
||||
int ret = 0;
|
||||
struct dh_gen_ctx *gctx = genctx;
|
||||
DH *dh = NULL;
|
||||
BN_GENCB *gencb = NULL;
|
||||
FFC_PARAMS *ffc;
|
||||
|
||||
if (gctx == NULL)
|
||||
return NULL;
|
||||
|
||||
/* For parameter generation - If there is a group name just create it */
|
||||
if (gctx->gen_type == DH_PARAMGEN_TYPE_GROUP) {
|
||||
/* Select a named group if there is not one already */
|
||||
if (gctx->group_nid == NID_undef)
|
||||
gctx->group_nid = dh_get_named_group_uid_from_size(gctx->pbits);
|
||||
if (gctx->group_nid == NID_undef)
|
||||
return NULL;
|
||||
dh = dh_new_by_nid_with_libctx(gctx->libctx, gctx->group_nid);
|
||||
if (dh == NULL)
|
||||
return NULL;
|
||||
ffc = dh_get0_params(dh);
|
||||
} else {
|
||||
dh = dh_new_with_libctx(gctx->libctx);
|
||||
if (dh == NULL)
|
||||
return NULL;
|
||||
ffc = dh_get0_params(dh);
|
||||
|
||||
/* Copy the template value if one was passed */
|
||||
if (gctx->ffc_params != NULL
|
||||
&& !ffc_params_copy(ffc, gctx->ffc_params))
|
||||
goto end;
|
||||
|
||||
if (!ffc_params_set_seed(ffc, gctx->seed, gctx->seedlen))
|
||||
goto end;
|
||||
if (gctx->gindex != -1) {
|
||||
ffc_params_set_gindex(ffc, gctx->gindex);
|
||||
if (gctx->pcounter != -1)
|
||||
ffc_params_set_pcounter(ffc, gctx->pcounter);
|
||||
} else if (gctx->hindex != 0) {
|
||||
ffc_params_set_h(ffc, gctx->hindex);
|
||||
}
|
||||
gctx->cb = osslcb;
|
||||
gctx->cbarg = cbarg;
|
||||
gencb = BN_GENCB_new();
|
||||
if (gencb != NULL)
|
||||
BN_GENCB_set(gencb, dh_gencb, genctx);
|
||||
|
||||
if ((gctx->selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0) {
|
||||
/*
|
||||
* NOTE: The old safe prime generator code is not used in fips mode,
|
||||
* (i.e internally it ignores the generator and chooses a named
|
||||
* group based on pbits.
|
||||
*/
|
||||
if (gctx->gen_type == DH_PARAMGEN_TYPE_GENERATOR)
|
||||
ret = DH_generate_parameters_ex(dh, gctx->pbits,
|
||||
gctx->generator, gencb);
|
||||
else
|
||||
ret = dh_generate_ffc_parameters(dh, gctx->gen_type, gctx->pbits,
|
||||
gctx->qbits, gctx->md, gencb);
|
||||
if (ret <= 0)
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
if ((gctx->selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) {
|
||||
if (ffc->p == NULL || ffc->g == NULL)
|
||||
goto end;
|
||||
if (gctx->priv_len > 0)
|
||||
DH_set_length(dh, (long)gctx->priv_len);
|
||||
if (DH_generate_key(dh) <= 0)
|
||||
goto end;
|
||||
}
|
||||
ret = 1;
|
||||
end:
|
||||
if (ret <= 0) {
|
||||
DH_free(dh);
|
||||
dh = NULL;
|
||||
}
|
||||
BN_GENCB_free(gencb);
|
||||
return dh;
|
||||
}
|
||||
|
||||
static void dh_gen_cleanup(void *genctx)
|
||||
{
|
||||
struct dh_gen_ctx *gctx = genctx;
|
||||
|
||||
if (gctx == NULL)
|
||||
return;
|
||||
|
||||
OPENSSL_clear_free(gctx->seed, gctx->seedlen);
|
||||
EVP_MD_free(gctx->md);
|
||||
OPENSSL_free(gctx);
|
||||
}
|
||||
|
||||
const OSSL_DISPATCH dh_keymgmt_functions[] = {
|
||||
{ OSSL_FUNC_KEYMGMT_NEW, (void (*)(void))dh_newdata },
|
||||
{ OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))dh_gen_init },
|
||||
{ OSSL_FUNC_KEYMGMT_GEN_SET_TEMPLATE, (void (*)(void))dh_gen_set_template },
|
||||
{ OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS, (void (*)(void))dh_gen_set_params },
|
||||
{ OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS,
|
||||
(void (*)(void))dh_gen_settable_params },
|
||||
{ OSSL_FUNC_KEYMGMT_GEN, (void (*)(void))dh_gen },
|
||||
{ OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))dh_gen_cleanup },
|
||||
{ OSSL_FUNC_KEYMGMT_FREE, (void (*)(void))dh_freedata },
|
||||
{ OSSL_FUNC_KEYMGMT_GET_PARAMS, (void (*) (void))dh_get_params },
|
||||
{ OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, (void (*) (void))dh_gettable_params },
|
||||
|
||||
@@ -13,18 +13,27 @@
|
||||
*/
|
||||
#include "internal/deprecated.h"
|
||||
|
||||
#include "e_os.h" /* strcasecmp */
|
||||
#include <openssl/core_numbers.h>
|
||||
#include <openssl/core_names.h>
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/params.h>
|
||||
#include "prov/implementations.h"
|
||||
#include <openssl/err.h>
|
||||
#include "prov/providercommon.h"
|
||||
#include "prov/implementations.h"
|
||||
#include "prov/provider_ctx.h"
|
||||
#include "crypto/dsa.h"
|
||||
#include "openssl/param_build.h"
|
||||
#include "internal/sizes.h"
|
||||
#include "internal/nelem.h"
|
||||
#include "internal/param_build_set.h"
|
||||
|
||||
static OSSL_OP_keymgmt_new_fn dsa_newdata;
|
||||
static OSSL_OP_keymgmt_free_fn dsa_freedata;
|
||||
static OSSL_OP_keymgmt_gen_init_fn dsa_gen_init;
|
||||
static OSSL_OP_keymgmt_gen_set_template_fn dsa_gen_set_template;
|
||||
static OSSL_OP_keymgmt_gen_set_params_fn dsa_gen_set_params;
|
||||
static OSSL_OP_keymgmt_gen_settable_params_fn dsa_gen_settable_params;
|
||||
static OSSL_OP_keymgmt_gen_fn dsa_gen;
|
||||
static OSSL_OP_keymgmt_gen_cleanup_fn dsa_gen_cleanup;
|
||||
static OSSL_OP_keymgmt_get_params_fn dsa_get_params;
|
||||
static OSSL_OP_keymgmt_gettable_params_fn dsa_gettable_params;
|
||||
static OSSL_OP_keymgmt_has_fn dsa_has;
|
||||
@@ -36,45 +45,63 @@ static OSSL_OP_keymgmt_export_fn dsa_export;
|
||||
static OSSL_OP_keymgmt_export_types_fn dsa_export_types;
|
||||
|
||||
#define DSA_DEFAULT_MD "SHA256"
|
||||
#define DSA_POSSIBLE_SELECTIONS \
|
||||
#define DSA_POSSIBLE_SELECTIONS \
|
||||
(OSSL_KEYMGMT_SELECT_KEYPAIR | OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS)
|
||||
|
||||
static int domparams_to_params(DSA *dsa, OSSL_PARAM_BLD *tmpl)
|
||||
struct dsa_gen_ctx {
|
||||
OPENSSL_CTX *libctx;
|
||||
|
||||
FFC_PARAMS *ffc_params;
|
||||
int selection;
|
||||
/* All these parameters are used for parameter generation only */
|
||||
size_t pbits;
|
||||
size_t qbits;
|
||||
EVP_MD *md;
|
||||
unsigned char *seed; /* optional FIPS186-4 param for testing */
|
||||
size_t seedlen;
|
||||
int gindex; /* optional FIPS186-4 generator index (ignored if -1) */
|
||||
int gen_type; /* DSA_PARAMGEN_TYPE_FIPS_186_2 or DSA_PARAMGEN_TYPE_FIPS_186_4 */
|
||||
int pcounter;
|
||||
int hindex;
|
||||
OSSL_CALLBACK *cb;
|
||||
void *cbarg;
|
||||
};
|
||||
typedef struct dh_name2id_st{
|
||||
const char *name;
|
||||
int id;
|
||||
} DSA_GENTYPE_NAME2ID;
|
||||
|
||||
static const DSA_GENTYPE_NAME2ID dsatype2id[]=
|
||||
{
|
||||
const BIGNUM *dsa_p = NULL, *dsa_q = NULL, *dsa_g = NULL;
|
||||
{ "default", DSA_PARAMGEN_TYPE_FIPS_186_4 },
|
||||
{ "fips186_4", DSA_PARAMGEN_TYPE_FIPS_186_4 },
|
||||
{ "fips186_2", DSA_PARAMGEN_TYPE_FIPS_186_2 },
|
||||
};
|
||||
|
||||
if (dsa == NULL)
|
||||
return 0;
|
||||
static int dsa_gen_type_name2id(const char *name)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
DSA_get0_pqg(dsa, &dsa_p, &dsa_q, &dsa_g);
|
||||
if (dsa_p != NULL
|
||||
&& !OSSL_PARAM_BLD_push_BN(tmpl, OSSL_PKEY_PARAM_FFC_P, dsa_p))
|
||||
return 0;
|
||||
if (dsa_q != NULL
|
||||
&& !OSSL_PARAM_BLD_push_BN(tmpl, OSSL_PKEY_PARAM_FFC_Q, dsa_q))
|
||||
return 0;
|
||||
if (dsa_g != NULL
|
||||
&& !OSSL_PARAM_BLD_push_BN(tmpl, OSSL_PKEY_PARAM_FFC_G, dsa_g))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
for (i = 0; i < OSSL_NELEM(dsatype2id); ++i) {
|
||||
if (strcasecmp(dsatype2id[i].name, name) == 0)
|
||||
return dsatype2id[i].id;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int key_to_params(DSA *dsa, OSSL_PARAM_BLD *tmpl)
|
||||
static int dsa_key_todata(DSA *dsa, OSSL_PARAM_BLD *bld, OSSL_PARAM params[])
|
||||
{
|
||||
const BIGNUM *priv_key = NULL, *pub_key = NULL;
|
||||
const BIGNUM *priv = NULL, *pub = NULL;
|
||||
|
||||
if (dsa == NULL)
|
||||
return 0;
|
||||
if (!domparams_to_params(dsa, tmpl))
|
||||
return 0;
|
||||
|
||||
DSA_get0_key(dsa, &pub_key, &priv_key);
|
||||
if (priv_key != NULL
|
||||
&& !OSSL_PARAM_BLD_push_BN(tmpl, OSSL_PKEY_PARAM_PRIV_KEY, priv_key))
|
||||
DSA_get0_key(dsa, &pub, &priv);
|
||||
if (priv != NULL
|
||||
&& !ossl_param_build_set_bn(bld, params, OSSL_PKEY_PARAM_PRIV_KEY, priv))
|
||||
return 0;
|
||||
if (pub_key != NULL
|
||||
&& !OSSL_PARAM_BLD_push_BN(tmpl, OSSL_PKEY_PARAM_PUB_KEY, pub_key))
|
||||
if (pub != NULL
|
||||
&& !ossl_param_build_set_bn(bld, params, OSSL_PKEY_PARAM_PUB_KEY, pub))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
@@ -133,16 +160,16 @@ static int dsa_match(const void *keydata1, const void *keydata2, int selection)
|
||||
static int dsa_import(void *keydata, int selection, const OSSL_PARAM params[])
|
||||
{
|
||||
DSA *dsa = keydata;
|
||||
int ok = 0;
|
||||
int ok = 1;
|
||||
|
||||
if (dsa == NULL)
|
||||
return 0;
|
||||
|
||||
if ((selection & DSA_POSSIBLE_SELECTIONS) != 0)
|
||||
ok = 1;
|
||||
if ((selection & DSA_POSSIBLE_SELECTIONS) == 0)
|
||||
return 0;
|
||||
|
||||
if ((selection & OSSL_KEYMGMT_SELECT_ALL_PARAMETERS) != 0)
|
||||
ok = ok && ffc_fromdata(dsa_get0_params(dsa), params);
|
||||
ok = ok && dsa_ffc_params_fromdata(dsa, params);
|
||||
if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0)
|
||||
ok = ok && dsa_key_fromdata(dsa, params);
|
||||
|
||||
@@ -158,12 +185,12 @@ static int dsa_export(void *keydata, int selection, OSSL_CALLBACK *param_cb,
|
||||
int ok = 1;
|
||||
|
||||
if (dsa == NULL)
|
||||
goto err;;
|
||||
goto err;
|
||||
|
||||
if ((selection & OSSL_KEYMGMT_SELECT_ALL_PARAMETERS) != 0)
|
||||
ok = ok && domparams_to_params(dsa, tmpl);
|
||||
ok = ok && ffc_params_todata(dsa_get0_params(dsa), tmpl, NULL);
|
||||
if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0)
|
||||
ok = ok && key_to_params(dsa, tmpl);
|
||||
ok = ok && dsa_key_todata(dsa, tmpl, NULL);
|
||||
|
||||
if (!ok
|
||||
|| (params = OSSL_PARAM_BLD_to_param(tmpl)) == NULL)
|
||||
@@ -178,10 +205,16 @@ err:
|
||||
|
||||
/* IMEXPORT = IMPORT + EXPORT */
|
||||
|
||||
# define DSA_IMEXPORTABLE_PARAMETERS \
|
||||
OSSL_PARAM_BN(OSSL_PKEY_PARAM_FFC_P, NULL, 0), \
|
||||
OSSL_PARAM_BN(OSSL_PKEY_PARAM_FFC_Q, NULL, 0), \
|
||||
OSSL_PARAM_BN(OSSL_PKEY_PARAM_FFC_G, NULL, 0)
|
||||
# define DSA_IMEXPORTABLE_PARAMETERS \
|
||||
OSSL_PARAM_BN(OSSL_PKEY_PARAM_FFC_P, NULL, 0), \
|
||||
OSSL_PARAM_BN(OSSL_PKEY_PARAM_FFC_Q, NULL, 0), \
|
||||
OSSL_PARAM_BN(OSSL_PKEY_PARAM_FFC_G, NULL, 0), \
|
||||
OSSL_PARAM_BN(OSSL_PKEY_PARAM_FFC_COFACTOR, NULL, 0), \
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_FFC_GINDEX, NULL), \
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_FFC_PCOUNTER, NULL), \
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_FFC_H, NULL), \
|
||||
OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_FFC_GROUP, NULL, 0), \
|
||||
OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_FFC_SEED, NULL, 0)
|
||||
# define DSA_IMEXPORTABLE_PUBLIC_KEY \
|
||||
OSSL_PARAM_BN(OSSL_PKEY_PARAM_PUB_KEY, NULL, 0)
|
||||
# define DSA_IMEXPORTABLE_PRIVATE_KEY \
|
||||
@@ -246,7 +279,8 @@ static ossl_inline int dsa_get_params(void *key, OSSL_PARAM params[])
|
||||
if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_DEFAULT_DIGEST)) != NULL
|
||||
&& !OSSL_PARAM_set_utf8_string(p, DSA_DEFAULT_MD))
|
||||
return 0;
|
||||
return 1;
|
||||
return ffc_params_todata(dsa_get0_params(dsa), NULL, params)
|
||||
&& dsa_key_todata(dsa, NULL, params);
|
||||
}
|
||||
|
||||
static const OSSL_PARAM dsa_params[] = {
|
||||
@@ -254,6 +288,9 @@ static const OSSL_PARAM dsa_params[] = {
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_SECURITY_BITS, NULL),
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_MAX_SIZE, NULL),
|
||||
OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_DEFAULT_DIGEST, NULL, 0),
|
||||
DSA_IMEXPORTABLE_PARAMETERS,
|
||||
DSA_IMEXPORTABLE_PUBLIC_KEY,
|
||||
DSA_IMEXPORTABLE_PRIVATE_KEY,
|
||||
OSSL_PARAM_END
|
||||
};
|
||||
|
||||
@@ -311,8 +348,224 @@ static int dsa_validate(void *keydata, int selection)
|
||||
return ok;
|
||||
}
|
||||
|
||||
static void *dsa_gen_init(void *provctx, int selection)
|
||||
{
|
||||
OPENSSL_CTX *libctx = PROV_LIBRARY_CONTEXT_OF(provctx);
|
||||
struct dsa_gen_ctx *gctx = NULL;
|
||||
|
||||
if ((selection & DSA_POSSIBLE_SELECTIONS) == 0)
|
||||
return NULL;
|
||||
|
||||
if ((gctx = OPENSSL_zalloc(sizeof(*gctx))) != NULL) {
|
||||
gctx->selection = selection;
|
||||
gctx->libctx = libctx;
|
||||
gctx->pbits = 2048;
|
||||
gctx->qbits = 224;
|
||||
gctx->md = NULL;
|
||||
gctx->gen_type = DSA_PARAMGEN_TYPE_FIPS_186_4;
|
||||
gctx->gindex = -1;
|
||||
gctx->pcounter = -1;
|
||||
gctx->hindex = 0;
|
||||
}
|
||||
return gctx;
|
||||
}
|
||||
|
||||
static int dsa_gen_set_template(void *genctx, void *templ)
|
||||
{
|
||||
struct dsa_gen_ctx *gctx = genctx;
|
||||
DSA *dsa = templ;
|
||||
|
||||
if (gctx == NULL || dsa == NULL)
|
||||
return 0;
|
||||
gctx->ffc_params = dsa_get0_params(dsa);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int dsa_set_gen_seed(struct dsa_gen_ctx *gctx, unsigned char *seed,
|
||||
size_t seedlen)
|
||||
{
|
||||
OPENSSL_clear_free(gctx->seed, gctx->seedlen);
|
||||
gctx->seed = NULL;
|
||||
gctx->seedlen = 0;
|
||||
if (seed != NULL && seedlen > 0) {
|
||||
gctx->seed = OPENSSL_memdup(seed, seedlen);
|
||||
if (gctx->seed == NULL)
|
||||
return 0;
|
||||
gctx->seedlen = seedlen;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int dsa_gen_set_params(void *genctx, const OSSL_PARAM params[])
|
||||
{
|
||||
struct dsa_gen_ctx *gctx = genctx;
|
||||
const OSSL_PARAM *p;
|
||||
|
||||
if (gctx == NULL)
|
||||
return 0;
|
||||
|
||||
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_TYPE);
|
||||
if (p != NULL) {
|
||||
if (p->data_type != OSSL_PARAM_UTF8_STRING
|
||||
|| ((gctx->gen_type = dsa_gen_type_name2id(p->data)) == -1)) {
|
||||
ERR_raise(ERR_LIB_PROV, ERR_R_PASSED_INVALID_ARGUMENT);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_GINDEX);
|
||||
if (p != NULL
|
||||
&& !OSSL_PARAM_get_int(p, &gctx->gindex))
|
||||
return 0;
|
||||
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_PCOUNTER);
|
||||
if (p != NULL
|
||||
&& !OSSL_PARAM_get_int(p, &gctx->pcounter))
|
||||
return 0;
|
||||
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_H);
|
||||
if (p != NULL
|
||||
&& !OSSL_PARAM_get_int(p, &gctx->hindex))
|
||||
return 0;
|
||||
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_SEED);
|
||||
if (p != NULL
|
||||
&& (p->data_type != OSSL_PARAM_OCTET_STRING
|
||||
|| !dsa_set_gen_seed(gctx, p->data, p->data_size)))
|
||||
return 0;
|
||||
if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_PBITS)) != NULL
|
||||
&& !OSSL_PARAM_get_size_t(p, &gctx->pbits))
|
||||
return 0;
|
||||
if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_QBITS)) != NULL
|
||||
&& !OSSL_PARAM_get_size_t(p, &gctx->qbits))
|
||||
return 0;
|
||||
p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_DIGEST);
|
||||
if (p != NULL) {
|
||||
const OSSL_PARAM *p1;
|
||||
char mdprops[OSSL_MAX_PROPQUERY_SIZE] = { '\0' };
|
||||
char *str = mdprops;
|
||||
|
||||
if (p->data_type != OSSL_PARAM_UTF8_STRING)
|
||||
return 0;
|
||||
p1 = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_FFC_DIGEST_PROPS);
|
||||
if (p1 != NULL) {
|
||||
if (!OSSL_PARAM_get_utf8_string(p1, &str, sizeof(mdprops)))
|
||||
return 0;
|
||||
}
|
||||
EVP_MD_free(gctx->md);
|
||||
gctx->md = EVP_MD_fetch(gctx->libctx, p->data, mdprops);
|
||||
if (gctx->md == NULL)
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const OSSL_PARAM *dsa_gen_settable_params(void *provctx)
|
||||
{
|
||||
static OSSL_PARAM settable[] = {
|
||||
OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_FFC_TYPE, NULL, 0),
|
||||
OSSL_PARAM_size_t(OSSL_PKEY_PARAM_FFC_PBITS, NULL),
|
||||
OSSL_PARAM_size_t(OSSL_PKEY_PARAM_FFC_QBITS, NULL),
|
||||
OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_FFC_DIGEST, NULL, 0),
|
||||
OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_FFC_DIGEST_PROPS, NULL, 0),
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_FFC_GINDEX, NULL),
|
||||
OSSL_PARAM_octet_string(OSSL_PKEY_PARAM_FFC_SEED, NULL, 0),
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_FFC_PCOUNTER, NULL),
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_FFC_H, NULL),
|
||||
OSSL_PARAM_END
|
||||
};
|
||||
return settable;
|
||||
}
|
||||
|
||||
static int dsa_gencb(int p, int n, BN_GENCB *cb)
|
||||
{
|
||||
struct dsa_gen_ctx *gctx = BN_GENCB_get_arg(cb);
|
||||
OSSL_PARAM params[] = { OSSL_PARAM_END, OSSL_PARAM_END, OSSL_PARAM_END };
|
||||
|
||||
params[0] = OSSL_PARAM_construct_int(OSSL_GEN_PARAM_POTENTIAL, &p);
|
||||
params[1] = OSSL_PARAM_construct_int(OSSL_GEN_PARAM_ITERATION, &n);
|
||||
|
||||
return gctx->cb(params, gctx->cbarg);
|
||||
}
|
||||
|
||||
static void *dsa_gen(void *genctx, OSSL_CALLBACK *osslcb, void *cbarg)
|
||||
{
|
||||
struct dsa_gen_ctx *gctx = genctx;
|
||||
DSA *dsa = NULL;
|
||||
BN_GENCB *gencb = NULL;
|
||||
int ret = 0;
|
||||
FFC_PARAMS *ffc;
|
||||
|
||||
if (gctx == NULL)
|
||||
return NULL;
|
||||
dsa = dsa_new_with_ctx(gctx->libctx);
|
||||
if (dsa == NULL)
|
||||
return NULL;
|
||||
|
||||
gctx->cb = osslcb;
|
||||
gctx->cbarg = cbarg;
|
||||
gencb = BN_GENCB_new();
|
||||
if (gencb != NULL)
|
||||
BN_GENCB_set(gencb, dsa_gencb, genctx);
|
||||
|
||||
ffc = dsa_get0_params(dsa);
|
||||
/* Copy the template value if one was passed */
|
||||
if (gctx->ffc_params != NULL
|
||||
&& !ffc_params_copy(ffc, gctx->ffc_params))
|
||||
goto end;
|
||||
|
||||
if (gctx->seed != NULL
|
||||
&& !ffc_params_set_seed(ffc, gctx->seed, gctx->seedlen))
|
||||
goto end;
|
||||
if (gctx->gindex != -1) {
|
||||
ffc_params_set_gindex(ffc, gctx->gindex);
|
||||
if (gctx->pcounter != -1)
|
||||
ffc_params_set_pcounter(ffc, gctx->pcounter);
|
||||
} else if (gctx->hindex != 0) {
|
||||
ffc_params_set_h(ffc, gctx->hindex);
|
||||
}
|
||||
if ((gctx->selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0) {
|
||||
|
||||
if (dsa_generate_ffc_parameters(dsa, gctx->gen_type,
|
||||
gctx->pbits, gctx->qbits, gctx->md,
|
||||
gencb) <= 0)
|
||||
goto end;
|
||||
}
|
||||
if ((gctx->selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) {
|
||||
if (ffc->p == NULL
|
||||
|| ffc->q == NULL
|
||||
|| ffc->g == NULL)
|
||||
goto end;
|
||||
if (DSA_generate_key(dsa) <= 0)
|
||||
goto end;
|
||||
}
|
||||
ret = 1;
|
||||
end:
|
||||
if (ret <= 0) {
|
||||
DSA_free(dsa);
|
||||
dsa = NULL;
|
||||
}
|
||||
BN_GENCB_free(gencb);
|
||||
return dsa;
|
||||
}
|
||||
|
||||
static void dsa_gen_cleanup(void *genctx)
|
||||
{
|
||||
struct dsa_gen_ctx *gctx = genctx;
|
||||
|
||||
if (gctx == NULL)
|
||||
return;
|
||||
|
||||
OPENSSL_clear_free(gctx->seed, gctx->seedlen);
|
||||
EVP_MD_free(gctx->md);
|
||||
OPENSSL_free(gctx);
|
||||
}
|
||||
|
||||
const OSSL_DISPATCH dsa_keymgmt_functions[] = {
|
||||
{ OSSL_FUNC_KEYMGMT_NEW, (void (*)(void))dsa_newdata },
|
||||
{ OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))dsa_gen_init },
|
||||
{ OSSL_FUNC_KEYMGMT_GEN_SET_TEMPLATE, (void (*)(void))dsa_gen_set_template },
|
||||
{ OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS, (void (*)(void))dsa_gen_set_params },
|
||||
{ OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS,
|
||||
(void (*)(void))dsa_gen_settable_params },
|
||||
{ OSSL_FUNC_KEYMGMT_GEN, (void (*)(void))dsa_gen },
|
||||
{ OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))dsa_gen_cleanup },
|
||||
{ OSSL_FUNC_KEYMGMT_FREE, (void (*)(void))dsa_freedata },
|
||||
{ OSSL_FUNC_KEYMGMT_GET_PARAMS, (void (*) (void))dsa_get_params },
|
||||
{ OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, (void (*) (void))dsa_gettable_params },
|
||||
|
||||
@@ -49,6 +49,7 @@ static OSSL_OP_keymgmt_export_fn ec_export;
|
||||
static OSSL_OP_keymgmt_export_types_fn ec_export_types;
|
||||
static OSSL_OP_keymgmt_query_operation_name_fn ec_query_operation_name;
|
||||
|
||||
#define EC_DEFAULT_MD "SHA256"
|
||||
#define EC_POSSIBLE_SELECTIONS \
|
||||
(OSSL_KEYMGMT_SELECT_KEYPAIR | OSSL_KEYMGMT_SELECT_ALL_PARAMETERS)
|
||||
|
||||
@@ -116,6 +117,7 @@ int key_to_params(const EC_KEY *eckey, OSSL_PARAM_BLD *tmpl,
|
||||
const EC_GROUP *ecg = NULL;
|
||||
size_t pub_key_len = 0;
|
||||
int ret = 0;
|
||||
BN_CTX *bnctx = NULL;
|
||||
|
||||
if (eckey == NULL
|
||||
|| (ecg = EC_KEY_get0_group(eckey)) == NULL)
|
||||
@@ -125,10 +127,18 @@ int key_to_params(const EC_KEY *eckey, OSSL_PARAM_BLD *tmpl,
|
||||
pub_point = EC_KEY_get0_public_key(eckey);
|
||||
|
||||
if (pub_point != NULL) {
|
||||
/*
|
||||
* EC_POINT_point2buf() can generate random numbers in some
|
||||
* implementations so we need to ensure we use the correct libctx.
|
||||
*/
|
||||
bnctx = BN_CTX_new_ex(ec_key_get_libctx(eckey));
|
||||
if (bnctx == NULL)
|
||||
goto err;
|
||||
|
||||
/* convert pub_point to a octet string according to the SECG standard */
|
||||
if ((pub_key_len = EC_POINT_point2buf(ecg, pub_point,
|
||||
POINT_CONVERSION_COMPRESSED,
|
||||
pub_key, NULL)) == 0
|
||||
pub_key, bnctx)) == 0
|
||||
|| !ossl_param_build_set_octet_string(tmpl, params,
|
||||
OSSL_PKEY_PARAM_PUB_KEY,
|
||||
*pub_key, pub_key_len))
|
||||
@@ -184,6 +194,7 @@ int key_to_params(const EC_KEY *eckey, OSSL_PARAM_BLD *tmpl,
|
||||
}
|
||||
ret = 1;
|
||||
err:
|
||||
BN_CTX_free(bnctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -481,6 +492,10 @@ int ec_get_params(void *key, OSSL_PARAM params[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_DEFAULT_DIGEST)) != NULL
|
||||
&& !OSSL_PARAM_set_utf8_string(p, EC_DEFAULT_MD))
|
||||
return 0;
|
||||
|
||||
p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_USE_COFACTOR_ECDH);
|
||||
if (p != NULL) {
|
||||
int ecdh_cofactor_mode = 0;
|
||||
|
||||
@@ -10,20 +10,42 @@
|
||||
#include <assert.h>
|
||||
#include <openssl/core_numbers.h>
|
||||
#include <openssl/core_names.h>
|
||||
#include <openssl/params.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/rand.h>
|
||||
#include "internal/param_build_set.h"
|
||||
#include "openssl/param_build.h"
|
||||
#include "crypto/ecx.h"
|
||||
#include "prov/implementations.h"
|
||||
#include "prov/providercommon.h"
|
||||
#include "internal/param_build_set.h"
|
||||
#include "prov/provider_ctx.h"
|
||||
#ifdef S390X_EC_ASM
|
||||
# include "s390x_arch.h"
|
||||
# include <openssl/sha.h> /* For SHA512_DIGEST_LENGTH */
|
||||
#endif
|
||||
|
||||
static OSSL_OP_keymgmt_new_fn x25519_new_key;
|
||||
static OSSL_OP_keymgmt_new_fn x448_new_key;
|
||||
static OSSL_OP_keymgmt_new_fn ed25519_new_key;
|
||||
static OSSL_OP_keymgmt_new_fn ed448_new_key;
|
||||
static OSSL_OP_keymgmt_gen_init_fn x25519_gen_init;
|
||||
static OSSL_OP_keymgmt_gen_init_fn x448_gen_init;
|
||||
static OSSL_OP_keymgmt_gen_init_fn ed25519_gen_init;
|
||||
static OSSL_OP_keymgmt_gen_init_fn ed448_gen_init;
|
||||
static OSSL_OP_keymgmt_gen_fn x25519_gen;
|
||||
static OSSL_OP_keymgmt_gen_fn x448_gen;
|
||||
static OSSL_OP_keymgmt_gen_fn ed25519_gen;
|
||||
static OSSL_OP_keymgmt_gen_fn ed448_gen;
|
||||
static OSSL_OP_keymgmt_gen_cleanup_fn ecx_gen_cleanup;
|
||||
static OSSL_OP_keymgmt_get_params_fn x25519_get_params;
|
||||
static OSSL_OP_keymgmt_get_params_fn x448_get_params;
|
||||
static OSSL_OP_keymgmt_get_params_fn ed25519_get_params;
|
||||
static OSSL_OP_keymgmt_get_params_fn ed448_get_params;
|
||||
static OSSL_OP_keymgmt_gettable_params_fn ecx_gettable_params;
|
||||
static OSSL_OP_keymgmt_gettable_params_fn x25519_gettable_params;
|
||||
static OSSL_OP_keymgmt_gettable_params_fn x448_gettable_params;
|
||||
static OSSL_OP_keymgmt_gettable_params_fn ed25519_gettable_params;
|
||||
static OSSL_OP_keymgmt_gettable_params_fn ed448_gettable_params;
|
||||
static OSSL_OP_keymgmt_has_fn ecx_has;
|
||||
static OSSL_OP_keymgmt_import_fn ecx_import;
|
||||
static OSSL_OP_keymgmt_import_types_fn ecx_imexport_types;
|
||||
@@ -32,6 +54,18 @@ static OSSL_OP_keymgmt_export_types_fn ecx_imexport_types;
|
||||
|
||||
#define ECX_POSSIBLE_SELECTIONS (OSSL_KEYMGMT_SELECT_KEYPAIR)
|
||||
|
||||
struct ecx_gen_ctx {
|
||||
OPENSSL_CTX *libctx;
|
||||
ECX_KEY_TYPE type;
|
||||
};
|
||||
|
||||
#ifdef S390X_EC_ASM
|
||||
static void *s390x_ecx_keygen25519(struct ecx_gen_ctx *gctx);
|
||||
static void *s390x_ecx_keygen448(struct ecx_gen_ctx *gctx);
|
||||
static void *s390x_ecd_keygen25519(struct ecx_gen_ctx *gctx);
|
||||
static void *s390x_ecd_keygen448(struct ecx_gen_ctx *gctx);
|
||||
#endif
|
||||
|
||||
static void *x25519_new_key(void *provctx)
|
||||
{
|
||||
return ecx_key_new(ECX_KEY_TYPE_X25519, 0);
|
||||
@@ -176,6 +210,17 @@ static int ecx_get_params(void *key, OSSL_PARAM params[], int bits, int secbits,
|
||||
return key_to_params(ecx, NULL, params);
|
||||
}
|
||||
|
||||
static int ed_get_params(void *key, OSSL_PARAM params[])
|
||||
{
|
||||
OSSL_PARAM *p;
|
||||
|
||||
if ((p = OSSL_PARAM_locate(params,
|
||||
OSSL_PKEY_PARAM_MANDATORY_DIGEST)) != NULL
|
||||
&& !OSSL_PARAM_set_utf8_string(p, ""))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int x25519_get_params(void *key, OSSL_PARAM params[])
|
||||
{
|
||||
return ecx_get_params(key, params, X25519_BITS, X25519_SECURITY_BITS,
|
||||
@@ -191,16 +236,27 @@ static int x448_get_params(void *key, OSSL_PARAM params[])
|
||||
static int ed25519_get_params(void *key, OSSL_PARAM params[])
|
||||
{
|
||||
return ecx_get_params(key, params, ED25519_BITS, ED25519_SECURITY_BITS,
|
||||
ED25519_KEYLEN);
|
||||
ED25519_KEYLEN)
|
||||
&& ed_get_params(key, params);
|
||||
}
|
||||
|
||||
static int ed448_get_params(void *key, OSSL_PARAM params[])
|
||||
{
|
||||
return ecx_get_params(key, params, ED448_BITS, ED448_SECURITY_BITS,
|
||||
ED448_KEYLEN);
|
||||
ED448_KEYLEN)
|
||||
&& ed_get_params(key, params);
|
||||
}
|
||||
|
||||
static const OSSL_PARAM ecx_params[] = {
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_BITS, NULL),
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_SECURITY_BITS, NULL),
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_MAX_SIZE, NULL),
|
||||
OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_MANDATORY_DIGEST, NULL, 0),
|
||||
ECX_KEY_TYPES(),
|
||||
OSSL_PARAM_END
|
||||
};
|
||||
|
||||
static const OSSL_PARAM ed_params[] = {
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_BITS, NULL),
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_SECURITY_BITS, NULL),
|
||||
OSSL_PARAM_int(OSSL_PKEY_PARAM_MAX_SIZE, NULL),
|
||||
@@ -208,22 +264,174 @@ static const OSSL_PARAM ecx_params[] = {
|
||||
OSSL_PARAM_END
|
||||
};
|
||||
|
||||
static const OSSL_PARAM *ecx_gettable_params(void)
|
||||
static const OSSL_PARAM *x25519_gettable_params(void)
|
||||
{
|
||||
return ecx_params;
|
||||
}
|
||||
|
||||
static const OSSL_PARAM *x448_gettable_params(void)
|
||||
{
|
||||
return ecx_params;
|
||||
}
|
||||
|
||||
static const OSSL_PARAM *ed25519_gettable_params(void)
|
||||
{
|
||||
return ed_params;
|
||||
}
|
||||
|
||||
static const OSSL_PARAM *ed448_gettable_params(void)
|
||||
{
|
||||
return ed_params;
|
||||
}
|
||||
|
||||
static void *ecx_gen_init(void *provctx, int selection, ECX_KEY_TYPE type)
|
||||
{
|
||||
OPENSSL_CTX *libctx = PROV_LIBRARY_CONTEXT_OF(provctx);
|
||||
struct ecx_gen_ctx *gctx = NULL;
|
||||
|
||||
if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) == 0)
|
||||
return NULL;
|
||||
|
||||
if ((gctx = OPENSSL_malloc(sizeof(*gctx))) != NULL) {
|
||||
gctx->libctx = libctx;
|
||||
gctx->type = type;
|
||||
}
|
||||
return gctx;
|
||||
}
|
||||
|
||||
static void *x25519_gen_init(void *provctx, int selection)
|
||||
{
|
||||
return ecx_gen_init(provctx, selection, ECX_KEY_TYPE_X25519);
|
||||
}
|
||||
|
||||
static void *x448_gen_init(void *provctx, int selection)
|
||||
{
|
||||
return ecx_gen_init(provctx, selection, ECX_KEY_TYPE_X448);
|
||||
}
|
||||
|
||||
static void *ed25519_gen_init(void *provctx, int selection)
|
||||
{
|
||||
return ecx_gen_init(provctx, selection, ECX_KEY_TYPE_ED25519);
|
||||
}
|
||||
|
||||
static void *ed448_gen_init(void *provctx, int selection)
|
||||
{
|
||||
return ecx_gen_init(provctx, selection, ECX_KEY_TYPE_ED448);
|
||||
}
|
||||
|
||||
static void *ecx_gen(struct ecx_gen_ctx *gctx)
|
||||
{
|
||||
ECX_KEY *key;
|
||||
unsigned char *privkey;
|
||||
|
||||
if (gctx == NULL)
|
||||
return NULL;
|
||||
if ((key = ecx_key_new(gctx->type, 0)) == NULL) {
|
||||
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
if ((privkey = ecx_key_allocate_privkey(key)) == NULL) {
|
||||
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
if (RAND_priv_bytes_ex(gctx->libctx, privkey, key->keylen) <= 0)
|
||||
goto err;
|
||||
switch (gctx->type) {
|
||||
case ECX_KEY_TYPE_X25519:
|
||||
privkey[0] &= 248;
|
||||
privkey[X25519_KEYLEN - 1] &= 127;
|
||||
privkey[X25519_KEYLEN - 1] |= 64;
|
||||
X25519_public_from_private(key->pubkey, privkey);
|
||||
break;
|
||||
case ECX_KEY_TYPE_X448:
|
||||
privkey[0] &= 252;
|
||||
privkey[X448_KEYLEN - 1] |= 128;
|
||||
X448_public_from_private(key->pubkey, privkey);
|
||||
break;
|
||||
case ECX_KEY_TYPE_ED25519:
|
||||
if (!ED25519_public_from_private(gctx->libctx, key->pubkey, privkey))
|
||||
goto err;
|
||||
break;
|
||||
case ECX_KEY_TYPE_ED448:
|
||||
if (!ED448_public_from_private(gctx->libctx, key->pubkey, privkey))
|
||||
goto err;
|
||||
break;
|
||||
}
|
||||
return key;
|
||||
err:
|
||||
ecx_key_free(key);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void *x25519_gen(void *genctx, OSSL_CALLBACK *osslcb, void *cbarg)
|
||||
{
|
||||
struct ecx_gen_ctx *gctx = genctx;
|
||||
|
||||
#ifdef S390X_EC_ASM
|
||||
if (OPENSSL_s390xcap_P.pcc[1] & S390X_CAPBIT(S390X_SCALAR_MULTIPLY_X25519))
|
||||
return s390x_ecx_keygen25519(gctx);
|
||||
#endif
|
||||
return ecx_gen(gctx);
|
||||
}
|
||||
|
||||
static void *x448_gen(void *genctx, OSSL_CALLBACK *osslcb, void *cbarg)
|
||||
{
|
||||
struct ecx_gen_ctx *gctx = genctx;
|
||||
|
||||
#ifdef S390X_EC_ASM
|
||||
if (OPENSSL_s390xcap_P.pcc[1] & S390X_CAPBIT(S390X_SCALAR_MULTIPLY_X448))
|
||||
return s390x_ecx_keygen448(gctx);
|
||||
#endif
|
||||
return ecx_gen(gctx);
|
||||
}
|
||||
|
||||
static void *ed25519_gen(void *genctx, OSSL_CALLBACK *osslcb, void *cbarg)
|
||||
{
|
||||
struct ecx_gen_ctx *gctx = genctx;
|
||||
#ifdef S390X_EC_ASM
|
||||
if (OPENSSL_s390xcap_P.pcc[1] & S390X_CAPBIT(S390X_SCALAR_MULTIPLY_ED25519)
|
||||
&& OPENSSL_s390xcap_P.kdsa[0] & S390X_CAPBIT(S390X_EDDSA_SIGN_ED25519)
|
||||
&& OPENSSL_s390xcap_P.kdsa[0]
|
||||
& S390X_CAPBIT(S390X_EDDSA_VERIFY_ED25519))
|
||||
return s390x_ecd_keygen25519(gctx);
|
||||
#endif
|
||||
return ecx_gen(gctx);
|
||||
}
|
||||
|
||||
static void *ed448_gen(void *genctx, OSSL_CALLBACK *osslcb, void *cbarg)
|
||||
{
|
||||
struct ecx_gen_ctx *gctx = genctx;
|
||||
|
||||
#ifdef S390X_EC_ASM
|
||||
if (OPENSSL_s390xcap_P.pcc[1] & S390X_CAPBIT(S390X_SCALAR_MULTIPLY_ED448)
|
||||
&& OPENSSL_s390xcap_P.kdsa[0] & S390X_CAPBIT(S390X_EDDSA_SIGN_ED448)
|
||||
&& OPENSSL_s390xcap_P.kdsa[0] & S390X_CAPBIT(S390X_EDDSA_VERIFY_ED448))
|
||||
return s390x_ecd_keygen448(gctx);
|
||||
#endif
|
||||
return ecx_gen(gctx);
|
||||
}
|
||||
|
||||
static void ecx_gen_cleanup(void *genctx)
|
||||
{
|
||||
struct ecx_gen_ctx *gctx = genctx;
|
||||
|
||||
OPENSSL_free(gctx);
|
||||
}
|
||||
|
||||
#define MAKE_KEYMGMT_FUNCTIONS(alg) \
|
||||
const OSSL_DISPATCH alg##_keymgmt_functions[] = { \
|
||||
{ OSSL_FUNC_KEYMGMT_NEW, (void (*)(void))alg##_new_key }, \
|
||||
{ OSSL_FUNC_KEYMGMT_FREE, (void (*)(void))ecx_key_free }, \
|
||||
{ OSSL_FUNC_KEYMGMT_GET_PARAMS, (void (*) (void))alg##_get_params }, \
|
||||
{ OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, (void (*) (void))ecx_gettable_params }, \
|
||||
{ OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, (void (*) (void))alg##_gettable_params }, \
|
||||
{ OSSL_FUNC_KEYMGMT_HAS, (void (*)(void))ecx_has }, \
|
||||
{ OSSL_FUNC_KEYMGMT_IMPORT, (void (*)(void))ecx_import }, \
|
||||
{ OSSL_FUNC_KEYMGMT_IMPORT_TYPES, (void (*)(void))ecx_imexport_types }, \
|
||||
{ OSSL_FUNC_KEYMGMT_EXPORT, (void (*)(void))ecx_export }, \
|
||||
{ OSSL_FUNC_KEYMGMT_EXPORT_TYPES, (void (*)(void))ecx_imexport_types }, \
|
||||
{ OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))alg##_gen_init }, \
|
||||
{ OSSL_FUNC_KEYMGMT_GEN, (void (*)(void))alg##_gen }, \
|
||||
{ OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))ecx_gen_cleanup }, \
|
||||
{ 0, NULL } \
|
||||
};
|
||||
|
||||
@@ -231,3 +439,212 @@ MAKE_KEYMGMT_FUNCTIONS(x25519)
|
||||
MAKE_KEYMGMT_FUNCTIONS(x448)
|
||||
MAKE_KEYMGMT_FUNCTIONS(ed25519)
|
||||
MAKE_KEYMGMT_FUNCTIONS(ed448)
|
||||
|
||||
#ifdef S390X_EC_ASM
|
||||
# include "s390x_arch.h"
|
||||
|
||||
static void *s390x_ecx_keygen25519(struct ecx_gen_ctx *gctx)
|
||||
{
|
||||
static const unsigned char generator[] = {
|
||||
0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
ECX_KEY *key = ecx_key_new(ECX_KEY_TYPE_X25519, 1);
|
||||
unsigned char *privkey = NULL, *pubkey;
|
||||
|
||||
if (key == NULL) {
|
||||
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
pubkey = key->pubkey;
|
||||
|
||||
privkey = ecx_key_allocate_privkey(key);
|
||||
if (privkey == NULL) {
|
||||
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (RAND_priv_bytes_ex(gctx->libctx, privkey, X25519_KEYLEN) <= 0)
|
||||
goto err;
|
||||
|
||||
privkey[0] &= 248;
|
||||
privkey[31] &= 127;
|
||||
privkey[31] |= 64;
|
||||
|
||||
if (s390x_x25519_mul(pubkey, generator, privkey) != 1)
|
||||
goto err;
|
||||
return key;
|
||||
err:
|
||||
ecx_key_free(key);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void *s390x_ecx_keygen448(struct ecx_gen_ctx *gctx)
|
||||
{
|
||||
static const unsigned char generator[] = {
|
||||
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
ECX_KEY *key = ecx_key_new(ECX_KEY_TYPE_X448, 1);
|
||||
unsigned char *privkey = NULL, *pubkey;
|
||||
|
||||
if (key == NULL) {
|
||||
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
pubkey = key->pubkey;
|
||||
|
||||
privkey = ecx_key_allocate_privkey(key);
|
||||
if (privkey == NULL) {
|
||||
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (RAND_priv_bytes_ex(gctx->libctx, privkey, X448_KEYLEN) <= 0)
|
||||
goto err;
|
||||
|
||||
privkey[0] &= 252;
|
||||
privkey[55] |= 128;
|
||||
|
||||
if (s390x_x448_mul(pubkey, generator, privkey) != 1)
|
||||
goto err;
|
||||
return key;
|
||||
err:
|
||||
ecx_key_free(key);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void *s390x_ecd_keygen25519(struct ecx_gen_ctx *gctx)
|
||||
{
|
||||
static const unsigned char generator_x[] = {
|
||||
0x1a, 0xd5, 0x25, 0x8f, 0x60, 0x2d, 0x56, 0xc9, 0xb2, 0xa7, 0x25, 0x95,
|
||||
0x60, 0xc7, 0x2c, 0x69, 0x5c, 0xdc, 0xd6, 0xfd, 0x31, 0xe2, 0xa4, 0xc0,
|
||||
0xfe, 0x53, 0x6e, 0xcd, 0xd3, 0x36, 0x69, 0x21
|
||||
};
|
||||
static const unsigned char generator_y[] = {
|
||||
0x58, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
|
||||
0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
|
||||
0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,
|
||||
};
|
||||
unsigned char x_dst[32], buff[SHA512_DIGEST_LENGTH];
|
||||
ECX_KEY *key = ecx_key_new(ECX_KEY_TYPE_ED25519, 1);
|
||||
unsigned char *privkey = NULL, *pubkey;
|
||||
unsigned int sz;
|
||||
EVP_MD *sha = NULL;
|
||||
int j;
|
||||
|
||||
if (key == NULL) {
|
||||
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
pubkey = key->pubkey;
|
||||
|
||||
privkey = ecx_key_allocate_privkey(key);
|
||||
if (privkey == NULL) {
|
||||
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (RAND_priv_bytes_ex(gctx->libctx, privkey, ED25519_KEYLEN) <= 0)
|
||||
goto err;
|
||||
|
||||
sha = EVP_MD_fetch(gctx->libctx, "SHA512", NULL);
|
||||
if (sha == NULL)
|
||||
goto err;
|
||||
j = EVP_Digest(privkey, 32, buff, &sz, sha, NULL);
|
||||
EVP_MD_free(sha);
|
||||
if (!j)
|
||||
goto err;
|
||||
|
||||
buff[0] &= 248;
|
||||
buff[31] &= 63;
|
||||
buff[31] |= 64;
|
||||
|
||||
if (s390x_ed25519_mul(x_dst, pubkey,
|
||||
generator_x, generator_y, buff) != 1)
|
||||
goto err;
|
||||
|
||||
pubkey[31] |= ((x_dst[0] & 0x01) << 7);
|
||||
return key;
|
||||
err:
|
||||
ecx_key_free(key);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void *s390x_ecd_keygen448(struct ecx_gen_ctx *gctx)
|
||||
{
|
||||
static const unsigned char generator_x[] = {
|
||||
0x5e, 0xc0, 0x0c, 0xc7, 0x2b, 0xa8, 0x26, 0x26, 0x8e, 0x93, 0x00, 0x8b,
|
||||
0xe1, 0x80, 0x3b, 0x43, 0x11, 0x65, 0xb6, 0x2a, 0xf7, 0x1a, 0xae, 0x12,
|
||||
0x64, 0xa4, 0xd3, 0xa3, 0x24, 0xe3, 0x6d, 0xea, 0x67, 0x17, 0x0f, 0x47,
|
||||
0x70, 0x65, 0x14, 0x9e, 0xda, 0x36, 0xbf, 0x22, 0xa6, 0x15, 0x1d, 0x22,
|
||||
0xed, 0x0d, 0xed, 0x6b, 0xc6, 0x70, 0x19, 0x4f, 0x00
|
||||
};
|
||||
static const unsigned char generator_y[] = {
|
||||
0x14, 0xfa, 0x30, 0xf2, 0x5b, 0x79, 0x08, 0x98, 0xad, 0xc8, 0xd7, 0x4e,
|
||||
0x2c, 0x13, 0xbd, 0xfd, 0xc4, 0x39, 0x7c, 0xe6, 0x1c, 0xff, 0xd3, 0x3a,
|
||||
0xd7, 0xc2, 0xa0, 0x05, 0x1e, 0x9c, 0x78, 0x87, 0x40, 0x98, 0xa3, 0x6c,
|
||||
0x73, 0x73, 0xea, 0x4b, 0x62, 0xc7, 0xc9, 0x56, 0x37, 0x20, 0x76, 0x88,
|
||||
0x24, 0xbc, 0xb6, 0x6e, 0x71, 0x46, 0x3f, 0x69, 0x00
|
||||
};
|
||||
unsigned char x_dst[57], buff[114];
|
||||
ECX_KEY *key = ecx_key_new(ECX_KEY_TYPE_ED448, 1);
|
||||
unsigned char *privkey = NULL, *pubkey;
|
||||
EVP_MD_CTX *hashctx = NULL;
|
||||
EVP_MD *shake = NULL;
|
||||
|
||||
if (key == NULL) {
|
||||
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
pubkey = key->pubkey;
|
||||
|
||||
privkey = ecx_key_allocate_privkey(key);
|
||||
if (privkey == NULL) {
|
||||
ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
shake = EVP_MD_fetch(gctx->libctx, "SHAKE256", NULL);
|
||||
if (shake == NULL)
|
||||
goto err;
|
||||
if (RAND_priv_bytes_ex(gctx->libctx, privkey, ED448_KEYLEN) <= 0)
|
||||
goto err;
|
||||
|
||||
hashctx = EVP_MD_CTX_new();
|
||||
if (hashctx == NULL)
|
||||
goto err;
|
||||
if (EVP_DigestInit_ex(hashctx, shake, NULL) != 1)
|
||||
goto err;
|
||||
if (EVP_DigestUpdate(hashctx, privkey, 57) != 1)
|
||||
goto err;
|
||||
if (EVP_DigestFinalXOF(hashctx, buff, sizeof(buff)) != 1)
|
||||
goto err;
|
||||
|
||||
buff[0] &= -4;
|
||||
buff[55] |= 0x80;
|
||||
buff[56] = 0;
|
||||
|
||||
if (s390x_ed448_mul(x_dst, pubkey,
|
||||
generator_x, generator_y, buff) != 1)
|
||||
goto err;
|
||||
|
||||
pubkey[56] |= ((x_dst[0] & 0x01) << 7);
|
||||
EVP_MD_CTX_free(hashctx);
|
||||
EVP_MD_free(shake);
|
||||
return key;
|
||||
err:
|
||||
ecx_key_free(key);
|
||||
EVP_MD_CTX_free(hashctx);
|
||||
EVP_MD_free(shake);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
$SERIALIZER_GOAL=../../libimplementations.a
|
||||
$RSA_GOAL=../../libimplementations.a
|
||||
$FFC_GOAL=../../libimplementations.a
|
||||
$DH_GOAL=../../libimplementations.a
|
||||
$DSA_GOAL=../../libimplementations.a
|
||||
$ECX_GOAL=../../libimplementations.a
|
||||
@@ -10,6 +11,9 @@ $EC_GOAL=../../libimplementations.a
|
||||
|
||||
SOURCE[$SERIALIZER_GOAL]=serializer_common.c
|
||||
SOURCE[$RSA_GOAL]=serializer_rsa.c serializer_rsa_priv.c serializer_rsa_pub.c
|
||||
IF[{- !$disabled{"dh"} || !$disabled{"dsa"} -}]
|
||||
SOURCE[$FFC_GOAL]=serializer_ffc_params.c
|
||||
ENDIF
|
||||
IF[{- !$disabled{dh} -}]
|
||||
SOURCE[$DH_GOAL]=serializer_dh.c serializer_dh_priv.c serializer_dh_pub.c serializer_dh_param.c
|
||||
ENDIF
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <openssl/types.h>
|
||||
#include <openssl/x509.h> /* i2d_X509_PUBKEY_bio() */
|
||||
#include "crypto/bn.h" /* bn_get_words() */
|
||||
#include "crypto/ctype.h"
|
||||
#include "crypto/ecx.h"
|
||||
#include "prov/bio.h" /* ossl_prov_bio_printf() */
|
||||
#include "prov/implementations.h"
|
||||
@@ -161,11 +162,13 @@ OSSL_OP_keymgmt_import_fn *ossl_prov_get_keymgmt_import(const OSSL_DISPATCH *fns
|
||||
int ossl_prov_print_labeled_bignum(BIO *out, const char *label,
|
||||
const BIGNUM *bn)
|
||||
{
|
||||
const char *neg;
|
||||
int ret = 0, use_sep = 0;
|
||||
char *hex_str = NULL, *p;
|
||||
const char spaces[] = " ";
|
||||
const char *post_label_spc = " ";
|
||||
|
||||
const char *neg = "";
|
||||
int bytes;
|
||||
BN_ULONG *words;
|
||||
int n, i;
|
||||
|
||||
if (bn == NULL)
|
||||
return 0;
|
||||
@@ -174,74 +177,63 @@ int ossl_prov_print_labeled_bignum(BIO *out, const char *label,
|
||||
post_label_spc = "";
|
||||
}
|
||||
|
||||
bytes = BN_num_bytes(bn);
|
||||
words = bn_get_words(bn);
|
||||
neg = BN_is_negative(bn) ? "-" : "";
|
||||
|
||||
if (BN_is_zero(bn))
|
||||
return ossl_prov_bio_printf(out, "%s%s0\n", label, post_label_spc);
|
||||
|
||||
if (BN_num_bytes(bn) <= BN_BYTES)
|
||||
if (BN_num_bytes(bn) <= BN_BYTES) {
|
||||
BN_ULONG *words = bn_get_words(bn);
|
||||
|
||||
if (BN_is_negative(bn))
|
||||
neg = "-";
|
||||
|
||||
return ossl_prov_bio_printf(out,
|
||||
"%s%s%s" BN_FMTu " (%s0x" BN_FMTx ")\n",
|
||||
label, post_label_spc, neg, words[0],
|
||||
neg, words[0]);
|
||||
}
|
||||
|
||||
if (neg[0] == '-')
|
||||
hex_str = BN_bn2hex(bn);
|
||||
p = hex_str;
|
||||
if (*p == '-') {
|
||||
++p;
|
||||
neg = " (Negative)";
|
||||
|
||||
}
|
||||
if (ossl_prov_bio_printf(out, "%s%s\n", label, neg) <= 0)
|
||||
return 0;
|
||||
goto err;
|
||||
|
||||
/* Keep track of how many bytes we have printed out so far */
|
||||
n = 0;
|
||||
bytes = 0;
|
||||
|
||||
/*
|
||||
* OpenSSL BIGNUMs are little endian limbs, so we print them last to
|
||||
* first limb.
|
||||
* i is used as limb index, j is used as the "byte index" in the limb
|
||||
*/
|
||||
for (i = bytes / BN_BYTES - 1; i >= 0; i--) {
|
||||
BN_ULONG l = words[i];
|
||||
int j;
|
||||
if (ossl_prov_bio_printf(out, "%s", spaces) <= 0)
|
||||
goto err;
|
||||
|
||||
for (j = BN_BYTES - 1; j >= 0; j--) {
|
||||
int o = 8 * j;
|
||||
int b = ((l & (0xffLU << o)) >> o) & 0xff;
|
||||
|
||||
/* Indent every new line with 4 spaces */
|
||||
if ((n % 15) == 0) {
|
||||
if (n > 0)
|
||||
if (ossl_prov_bio_printf(out, "\n") <= 0)
|
||||
return 0;
|
||||
if (ossl_prov_bio_printf(out, " ") <= 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Upper bit set, then we print an extra zero and pretend the
|
||||
* BIGNUM was one byte longer
|
||||
*/
|
||||
if (n == 0 && b > 127) {
|
||||
if (ossl_prov_bio_printf(out, "%02x:", 0) <= 0)
|
||||
return 0;
|
||||
n++;
|
||||
bytes++;
|
||||
}
|
||||
|
||||
if (++n < bytes) {
|
||||
if (ossl_prov_bio_printf(out, "%02x:", b) <= 0)
|
||||
return 0;
|
||||
} else {
|
||||
if (ossl_prov_bio_printf(out, "%02x", b) <= 0)
|
||||
return 0;
|
||||
}
|
||||
/* Add a leading 00 if the top bit is set */
|
||||
if (*p >= '8') {
|
||||
if (ossl_prov_bio_printf(out, "%02x", 0) <= 0)
|
||||
goto err;
|
||||
++bytes;
|
||||
use_sep = 1;
|
||||
}
|
||||
while (*p != '\0') {
|
||||
/* Do a newline after every 15 hex bytes + add the space indent */
|
||||
if ((bytes % 15) == 0 && bytes > 0) {
|
||||
if (ossl_prov_bio_printf(out, ":\n%s", spaces) <= 0)
|
||||
goto err;
|
||||
use_sep = 0; /* The first byte on the next line doesnt have a : */
|
||||
}
|
||||
if (ossl_prov_bio_printf(out, "%s%c%c", use_sep ? ":" : "",
|
||||
ossl_tolower(p[0]), ossl_tolower(p[1])) <= 0)
|
||||
goto err;
|
||||
++bytes;
|
||||
p += 2;
|
||||
use_sep = 1;
|
||||
}
|
||||
if (ossl_prov_bio_printf(out, "\n") <= 0)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
goto err;
|
||||
ret = 1;
|
||||
err:
|
||||
OPENSSL_free(hex_str);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Number of octets per line */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -13,11 +13,12 @@
|
||||
*/
|
||||
#include "internal/deprecated.h"
|
||||
|
||||
#include <openssl/dh.h>
|
||||
#include <openssl/err.h>
|
||||
#include "prov/bio.h" /* ossl_prov_bio_printf() */
|
||||
#include "prov/implementations.h" /* rsa_keymgmt_functions */
|
||||
#include "prov/providercommonerr.h" /* PROV_R_BN_ERROR */
|
||||
#include "internal/ffc.h"
|
||||
#include "crypto/dh.h"
|
||||
#include "serializer_local.h"
|
||||
|
||||
OSSL_OP_keymgmt_new_fn *ossl_prov_get_keymgmt_dh_new(void)
|
||||
@@ -39,8 +40,7 @@ int ossl_prov_print_dh(BIO *out, DH *dh, enum dh_print_type type)
|
||||
{
|
||||
const char *type_label = NULL;
|
||||
const BIGNUM *priv_key = NULL, *pub_key = NULL;
|
||||
const BIGNUM *p = NULL, *g = NULL;
|
||||
|
||||
const BIGNUM *p = NULL;
|
||||
|
||||
switch (type) {
|
||||
case dh_print_priv:
|
||||
@@ -67,35 +67,19 @@ int ossl_prov_print_dh(BIO *out, DH *dh, enum dh_print_type type)
|
||||
}
|
||||
|
||||
p = DH_get0_p(dh);
|
||||
g = DH_get0_g(dh);
|
||||
if (p == NULL || g == NULL)
|
||||
if (p == NULL)
|
||||
goto null_err;
|
||||
|
||||
/*
|
||||
* TODO(3.0): add printing of:
|
||||
*
|
||||
* - q (label "subgroup order:")
|
||||
* - j (label "subgroup factor:")
|
||||
* - seed (label "seed:")
|
||||
* - counter (label "counter:")
|
||||
*
|
||||
* This can happen as soon as there are DH_get0_ functions for them.
|
||||
*/
|
||||
|
||||
if (ossl_prov_bio_printf(out, "%s: (%d bit)\n", type_label, BN_num_bits(p))
|
||||
<= 0)
|
||||
goto err;
|
||||
if (priv_key != NULL
|
||||
&& !ossl_prov_print_labeled_bignum(out, " private-key:", priv_key))
|
||||
&& !ossl_prov_print_labeled_bignum(out, "private-key:", priv_key))
|
||||
goto err;
|
||||
if (pub_key != NULL
|
||||
&& !ossl_prov_print_labeled_bignum(out, " public-key:", pub_key))
|
||||
&& !ossl_prov_print_labeled_bignum(out, "public-key:", pub_key))
|
||||
goto err;
|
||||
if (p != NULL
|
||||
&& !ossl_prov_print_labeled_bignum(out, " prime:", p))
|
||||
goto err;
|
||||
if (g != NULL
|
||||
&& !ossl_prov_print_labeled_bignum(out, " generator:", g))
|
||||
if (!ffc_params_prov_print(out, dh_get0_params(dh)))
|
||||
goto err;
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -19,6 +19,8 @@
|
||||
#include "prov/implementations.h" /* rsa_keymgmt_functions */
|
||||
#include "prov/providercommonerr.h" /* PROV_R_BN_ERROR */
|
||||
#include "serializer_local.h"
|
||||
#include "internal/ffc.h"
|
||||
#include "crypto/dsa.h"
|
||||
|
||||
OSSL_OP_keymgmt_new_fn *ossl_prov_get_keymgmt_dsa_new(void)
|
||||
{
|
||||
@@ -39,7 +41,7 @@ int ossl_prov_print_dsa(BIO *out, DSA *dsa, enum dsa_print_type type)
|
||||
{
|
||||
const char *type_label = NULL;
|
||||
const BIGNUM *priv_key = NULL, *pub_key = NULL;
|
||||
const BIGNUM *p = NULL, *q = NULL, *g = NULL;
|
||||
const BIGNUM *p = NULL;
|
||||
|
||||
|
||||
switch (type) {
|
||||
@@ -66,15 +68,13 @@ int ossl_prov_print_dsa(BIO *out, DSA *dsa, enum dsa_print_type type)
|
||||
goto null_err;
|
||||
}
|
||||
|
||||
p = DSA_get0_p(dsa);
|
||||
q = DSA_get0_q(dsa);
|
||||
g = DSA_get0_p(dsa);
|
||||
|
||||
if (p == NULL || q == NULL || g == NULL)
|
||||
p = DSA_get0_p(dsa);
|
||||
if (p == NULL)
|
||||
goto null_err;
|
||||
|
||||
if (ossl_prov_bio_printf(out, "%s: (%d bit)\n", type_label, BN_num_bits(p))
|
||||
<= 0)
|
||||
if (ossl_prov_bio_printf(out, "%s: (%d bit)\n", type_label,
|
||||
BN_num_bits(p)) <= 0)
|
||||
goto err;
|
||||
if (priv_key != NULL
|
||||
&& !ossl_prov_print_labeled_bignum(out, "priv:", priv_key))
|
||||
@@ -82,11 +82,7 @@ int ossl_prov_print_dsa(BIO *out, DSA *dsa, enum dsa_print_type type)
|
||||
if (pub_key != NULL
|
||||
&& !ossl_prov_print_labeled_bignum(out, "pub: ", pub_key))
|
||||
goto err;
|
||||
if (!ossl_prov_print_labeled_bignum(out, "P: ", p))
|
||||
goto err;
|
||||
if (!ossl_prov_print_labeled_bignum(out, "Q: ", q))
|
||||
goto err;
|
||||
if (!ossl_prov_print_labeled_bignum(out, "G: ", g))
|
||||
if (!ffc_params_prov_print(out, dsa_get0_params(dsa)))
|
||||
goto err;
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
*/
|
||||
|
||||
/* Utility function for printing DSA/DH params. */
|
||||
|
||||
#include "prov/bio.h"
|
||||
#include "serializer_local.h"
|
||||
|
||||
int ffc_params_prov_print(BIO *out, const FFC_PARAMS *ffc)
|
||||
{
|
||||
if (ffc->nid != NID_undef) {
|
||||
#ifndef OPENSSL_NO_DH
|
||||
const char *name = ffc_named_group_from_uid(ffc->nid);
|
||||
|
||||
if (name == NULL)
|
||||
goto err;
|
||||
if (ossl_prov_bio_printf(out, "GROUP: %s\n", name) <= 0)
|
||||
goto err;
|
||||
return 1;
|
||||
#else
|
||||
/* How could this be? We should not have a nid in a no-dh build. */
|
||||
goto err;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!ossl_prov_print_labeled_bignum(out, "P: ", ffc->p))
|
||||
goto err;
|
||||
if (ffc->q != NULL) {
|
||||
if (!ossl_prov_print_labeled_bignum(out, "Q: ", ffc->q))
|
||||
goto err;
|
||||
}
|
||||
if (!ossl_prov_print_labeled_bignum(out, "G: ", ffc->g))
|
||||
goto err;
|
||||
if (ffc->j != NULL) {
|
||||
if (!ossl_prov_print_labeled_bignum(out, "J: ", ffc->j))
|
||||
goto err;
|
||||
}
|
||||
if (ffc->seed != NULL) {
|
||||
if (!ossl_prov_print_labeled_buf(out, "SEED:", ffc->seed, ffc->seedlen))
|
||||
goto err;
|
||||
}
|
||||
if (ffc->gindex != -1) {
|
||||
if (ossl_prov_bio_printf(out, "gindex: %d\n", ffc->gindex) <= 0)
|
||||
goto err;
|
||||
}
|
||||
if (ffc->pcounter != -1) {
|
||||
if (ossl_prov_bio_printf(out, "pcounter: %d\n", ffc->pcounter) <= 0)
|
||||
goto err;
|
||||
}
|
||||
if (ffc->h != 0) {
|
||||
if (ossl_prov_bio_printf(out, "h: %d\n", ffc->h) <= 0)
|
||||
goto err;
|
||||
}
|
||||
return 1;
|
||||
err:
|
||||
return 0;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <openssl/x509.h> /* X509_SIG */
|
||||
#include <openssl/types.h>
|
||||
#include <crypto/ecx.h>
|
||||
#include "internal/ffc.h"
|
||||
|
||||
struct pkcs8_encrypt_ctx_st {
|
||||
/* Set to 1 if intending to encrypt/decrypt, otherwise 0 */
|
||||
@@ -54,6 +55,7 @@ int ossl_prov_prepare_ec_params(const void *eckey, int nid,
|
||||
int ossl_prov_ec_pub_to_der(const void *eckey, unsigned char **pder);
|
||||
int ossl_prov_ec_priv_to_der(const void *eckey, unsigned char **pder);
|
||||
|
||||
int ffc_params_prov_print(BIO *out, const FFC_PARAMS *ffc);
|
||||
int ossl_prov_prepare_dh_params(const void *dh, int nid,
|
||||
void **pstr, int *pstrtype);
|
||||
int ossl_prov_dh_pub_to_der(const void *dh, unsigned char **pder);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
Reference in New Issue
Block a user