diff --git a/Third_Party_Open_Source_Software_Notice b/Third_Party_Open_Source_Software_Notice index bb0a3a3f..ff466aaa 100644 --- a/Third_Party_Open_Source_Software_Notice +++ b/Third_Party_Open_Source_Software_Notice @@ -7,813 +7,3 @@ Warranty Disclaimer The open source software in this software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the applicable licenses for more details. Copyright Notice and License Texts - -Software: lksctp-tools v1.0.19 - -Copyright notice: - -(C) Copyright 2007 Hewlett-Packard Development Company, L.P. -(C) Copyright IBM Corp. 2001, 2003 -Copyright 2001 Motorola, Cisco, Intel, Nokia, La Monte Yarroll. -Copyright 2002 Nokia, La Monte Yarroll, Intel. - -License:LGPL-2.1 license; GPL-2.0 license - - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - - - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/bsl/include/bsl_binlog_id.h b/bsl/include/bsl_binlog_id.h index 9c2e8545..10321731 100644 --- a/bsl/include/bsl_binlog_id.h +++ b/bsl/include/bsl_binlog_id.h @@ -37,6 +37,7 @@ enum BSL_BINLOG_ID { BINLOG_ID05066, BINLOG_ID05067, BINLOG_ID05068, BINLOG_ID05069, BINLOG_ID05070, BINLOG_ID05071, BINLOG_ID05072, BINLOG_ID05073, BINLOG_ID05074, BINLOG_ID05075, BINLOG_ID05076, BINLOG_ID05077, BINLOG_ID05078, BINLOG_ID05079, BINLOG_ID05080, + BINLOG_ID05081, BINLOG_ID05082, BINLOG_ID05083, BINLOG_ID05084, BINLOG_ID05085, }; #ifdef __cplusplus diff --git a/bsl/sal/include/sal_net.h b/bsl/sal/include/sal_net.h index 01a0e8b3..fe096620 100644 --- a/bsl/sal/include/sal_net.h +++ b/bsl/sal/include/sal_net.h @@ -28,9 +28,6 @@ #include #endif -#ifdef HITLS_BSL_UIO_SCTP -#include -#endif #ifdef __cplusplus extern "C" { diff --git a/bsl/uio/src/uio_abstraction.c b/bsl/uio/src/uio_abstraction.c index 77fddda8..4c9e018d 100644 --- a/bsl/uio/src/uio_abstraction.c +++ b/bsl/uio/src/uio_abstraction.c @@ -25,7 +25,6 @@ #include "bsl_errno.h" #include "bsl_uio.h" #include "uio_base.h" -#include "uio_sctp.h" #include "uio_abstraction.h" BSL_UIO_Method *BSL_UIO_NewMethod(void) diff --git a/bsl/uio/src/uio_sctp.c b/bsl/uio/src/uio_sctp.c index a74035df..bc7c8730 100644 --- a/bsl/uio/src/uio_sctp.c +++ b/bsl/uio/src/uio_sctp.c @@ -29,30 +29,30 @@ #include "uio_base.h" #include "uio_abstraction.h" -#define SCTP_DATA_CHUNK_TYPE 0x00 -#define SCTP_FORWARD_TSN_CHUNK_TYPE 0xc0 -#define SCTP_GAUTH_CHUNKS_SIZE 256u -#define SCTP_SHARED_AUTHKEY_LEN 64u #define SCTP_SHARE_AUTHKEY_ID_MAX 65535 typedef struct { bool peerAuthed; /* Whether auth is enabled at the peer end */ /* Whether authkey is added: If authkey is added but not active, success is returned when authkey is added again. */ bool isAddAuthkey; - bool reverse[2]; /* Four-byte alignment is reserved. */ + bool reserved[2]; /* Four-byte alignment is reserved. */ uint16_t sendAppStreamId; /* ID of the stream sent by the user-specified app. */ uint16_t prevShareKeyId; uint16_t shareKeyId; - uint16_t reverse1; /* Four-byte alignment is reserved. */ + uint16_t reserved1; /* Four-byte alignment is reserved. */ +} BslSctpData; +typedef struct { + BslSctpData data; int32_t fd; // Network socket - uint8_t ip[IP_ADDR_MAX_LEN]; uint32_t ipLen; + uint8_t ip[IP_ADDR_MAX_LEN]; + struct BSL_UIO_MethodStruct method; bool isAppMsg; // whether the message sent is the app message } SctpParameters; -static int32_t SctpNew(BSL_UIO *uio) +static int32_t BslSctpNew(BSL_UIO *uio) { SctpParameters *parameters = (SctpParameters *)BSL_SAL_Calloc(1u, sizeof(SctpParameters)); if (parameters == NULL) { @@ -62,14 +62,14 @@ static int32_t SctpNew(BSL_UIO *uio) return BSL_UIO_FAIL; } parameters->fd = -1; + parameters->method.type = BSL_UIO_SCTP; uio->ctx = parameters; uio->ctxLen = sizeof(SctpParameters); - // Specifies whether to be closed by uio when setting fd. // The default value of init is 0. Set the value of init to 1 after the fd is set. return BSL_SUCCESS; } -static int32_t SctpDestroy(BSL_UIO *uio) +static int32_t BslSctpDestroy(BSL_UIO *uio) { if (uio == NULL) { return BSL_SUCCESS; @@ -86,9 +86,139 @@ static int32_t SctpDestroy(BSL_UIO *uio) return BSL_SUCCESS; } -static int32_t BslSctpGetSendStreamId(const BSL_UIO *uio, void *parg, int32_t larg) +static int32_t BslSctpWrite(BSL_UIO *uio, const void *buf, uint32_t len, uint32_t *writeLen) +{ + if (uio == NULL || uio->ctx == NULL || ((SctpParameters *)uio->ctx)->method.write == NULL) { + BSL_ERR_PUSH_ERROR(BSL_INVALID_ARG); + BSL_LOG_BINLOG_FIXLEN(BINLOG_ID05081, BSL_LOG_LEVEL_ERR, BSL_LOG_BINLOG_TYPE_RUN, + "Uio: Sctp write input error.", 0, 0, 0, 0); + return BSL_INVALID_ARG; + } + *writeLen = 0; + return ((SctpParameters *)uio->ctx)->method.write(uio, buf, len, writeLen); +} + +static int32_t BslSctpRead(BSL_UIO *uio, void *buf, uint32_t len, uint32_t *readLen) +{ + if (uio == NULL || uio->ctx == NULL || ((SctpParameters *)uio->ctx)->method.read == NULL) { + BSL_ERR_PUSH_ERROR(BSL_INVALID_ARG); + BSL_LOG_BINLOG_FIXLEN(BINLOG_ID05082, BSL_LOG_LEVEL_ERR, BSL_LOG_BINLOG_TYPE_RUN, + "Uio: Sctp read input error.", 0, 0, 0, 0); + return BSL_INVALID_ARG; + } + *readLen = 0; + SctpParameters *parameters = (SctpParameters *)uio->ctx; + if (!parameters->data.peerAuthed) { + if (parameters->method.ctrl == NULL || parameters->method.ctrl(uio, BSL_UIO_SCTP_CHECK_PEER_AUTH, + sizeof(parameters->data.peerAuthed), ¶meters->data.peerAuthed) != BSL_SUCCESS) { + BSL_ERR_PUSH_ERROR(BSL_UIO_IO_EXCEPTION); + BSL_LOG_BINLOG_FIXLEN(BINLOG_ID05083, BSL_LOG_LEVEL_ERR, BSL_LOG_BINLOG_TYPE_RUN, + "Uio: Check peer auth failed.", 0, 0, 0, 0); + return BSL_UIO_IO_EXCEPTION; + } + parameters->data.peerAuthed = true; + } + return parameters->method.read(uio, buf, len, readLen); +} + +static int32_t BslSctpAddAuthKey(BSL_UIO *uio, const uint8_t *parg, uint16_t larg) +{ + SctpParameters *parameters = (SctpParameters *)BSL_UIO_GetCtx(uio); + if (parg == NULL || larg != sizeof(BSL_UIO_SctpAuthKey)) { + BSL_ERR_PUSH_ERROR(BSL_INVALID_ARG); + BSL_LOG_BINLOG_FIXLEN(BINLOG_ID05062, BSL_LOG_LEVEL_ERR, BSL_LOG_BINLOG_TYPE_RUN, + "add auth key failed", 0, 0, 0, 0); + return BSL_INVALID_ARG; + } + + if (parameters->data.isAddAuthkey) { + return BSL_SUCCESS; + } + + uint16_t prevShareKeyId = parameters->data.shareKeyId; + if (parameters->data.shareKeyId >= SCTP_SHARE_AUTHKEY_ID_MAX) { + parameters->data.shareKeyId = 1; + } else { + parameters->data.shareKeyId++; + } + BSL_UIO_SctpAuthKey key = { 0 }; + key.shareKeyId = parameters->data.shareKeyId; + key.authKey = parg; + key.authKeySize = larg; + + int32_t ret = parameters->method.ctrl(uio, BSL_UIO_SCTP_ADD_AUTH_SHARED_KEY, (int32_t)sizeof(key), &key); + if (ret != BSL_SUCCESS) { + parameters->data.shareKeyId = prevShareKeyId; + BSL_ERR_PUSH_ERROR(BSL_UIO_IO_EXCEPTION); + BSL_LOG_BINLOG_FIXLEN(BINLOG_ID05065, BSL_LOG_LEVEL_ERR, BSL_LOG_BINLOG_TYPE_RUN, + "add auth key failed", 0, 0, 0, 0); + return BSL_UIO_IO_EXCEPTION; + } + parameters->data.isAddAuthkey = true; + parameters->data.prevShareKeyId = prevShareKeyId; + return BSL_SUCCESS; +} + +static int32_t BslSctpActiveAuthKey(BSL_UIO *uio) +{ + SctpParameters *parameters = BSL_UIO_GetCtx(uio); + if (parameters == NULL || parameters->method.ctrl == NULL) { + BSL_ERR_PUSH_ERROR(BSL_NULL_INPUT); + return BSL_NULL_INPUT; + } + uint16_t shareKeyId = parameters->data.shareKeyId; + int32_t ret = parameters->method.ctrl(uio, BSL_UIO_SCTP_ACTIVE_AUTH_SHARED_KEY, + (int32_t)sizeof(shareKeyId), &shareKeyId); + if (ret != BSL_SUCCESS) { + BSL_ERR_PUSH_ERROR(BSL_UIO_IO_EXCEPTION); + BSL_LOG_BINLOG_FIXLEN(BINLOG_ID05066, BSL_LOG_LEVEL_ERR, BSL_LOG_BINLOG_TYPE_RUN, + "active auth key failed", 0, 0, 0, 0); + return BSL_UIO_IO_EXCEPTION; + } + parameters->data.isAddAuthkey = false; + return BSL_SUCCESS; +} + +static int32_t BslSctpDelPreAuthKey(BSL_UIO *uio) +{ + SctpParameters *parameters = BSL_UIO_GetCtx(uio); + if (parameters == NULL || parameters->method.ctrl == NULL) { + BSL_ERR_PUSH_ERROR(BSL_NULL_INPUT); + return BSL_NULL_INPUT; + } + uint16_t delShareKeyId = parameters->data.prevShareKeyId; + int32_t ret = parameters->method.ctrl(uio, BSL_UIO_SCTP_DEL_PRE_AUTH_SHARED_KEY, + (int32_t)sizeof(delShareKeyId), &delShareKeyId); + if (ret != BSL_SUCCESS) { + BSL_ERR_PUSH_ERROR(BSL_UIO_IO_EXCEPTION); + BSL_LOG_BINLOG_FIXLEN(BINLOG_ID05067, BSL_LOG_LEVEL_ERR, BSL_LOG_BINLOG_TYPE_RUN, + "del pre auth key failed", 0, 0, 0, 0); + return BSL_UIO_IO_EXCEPTION; + } + return BSL_SUCCESS; +} + +static int32_t BslSctpIsSndBuffEmpty(BSL_UIO *uio, void *parg, int32_t larg) +{ + SctpParameters *parameters = BSL_UIO_GetCtx(uio); + if (parameters == NULL || parameters->method.ctrl == NULL || parg == NULL || larg != sizeof(bool)) { + BSL_ERR_PUSH_ERROR(BSL_NULL_INPUT); + return BSL_NULL_INPUT; + } + uint8_t isEmpty = 0; + if (parameters->method.ctrl(uio, BSL_UIO_SCTP_SND_BUFF_IS_EMPTY, + (int32_t)sizeof(uint8_t), &isEmpty) != BSL_SUCCESS) { + BSL_ERR_PUSH_ERROR(BSL_UIO_IO_EXCEPTION); + BSL_LOG_BINLOG_FIXLEN(BINLOG_ID05068, BSL_LOG_LEVEL_ERR, BSL_LOG_BINLOG_TYPE_RUN, + "get sctp status failed", 0, 0, 0, 0); + return BSL_UIO_IO_EXCEPTION; + } + *(bool *)parg = (isEmpty > 0); + return BSL_SUCCESS; +} + +static int32_t BslSctpGetSendStreamId(const SctpParameters *parameters, void *parg, int32_t larg) { - SctpParameters *parameters = uio->ctx; if (larg != (int32_t)sizeof(uint16_t) || parg == NULL) { BSL_LOG_BINLOG_FIXLEN(BINLOG_ID05046, BSL_LOG_LEVEL_ERR, BSL_LOG_BINLOG_TYPE_RUN, "Uio: Sctp input err.", 0, 0, 0, 0); @@ -97,7 +227,7 @@ static int32_t BslSctpGetSendStreamId(const BSL_UIO *uio, void *parg, int32_t la } uint16_t *sendStreamId = (uint16_t *)parg; if (parameters->isAppMsg) { - *sendStreamId = parameters->sendAppStreamId; + *sendStreamId = parameters->data.sendAppStreamId; } else { *sendStreamId = 0; } @@ -115,13 +245,13 @@ int32_t BslSctpSetAppStreamId(SctpParameters *parameters, const void *parg, int3 BSL_ERR_PUSH_ERROR(BSL_NULL_INPUT); return BSL_NULL_INPUT; } - parameters->sendAppStreamId = *(const uint16_t *)parg; + parameters->data.sendAppStreamId = *(const uint16_t *)parg; BSL_LOG_BINLOG_FIXLEN(BINLOG_ID05055, BSL_LOG_LEVEL_DEBUG, BSL_LOG_BINLOG_TYPE_RUN, - "Uio: User set SCTP AppStreamId [%hu].", parameters->sendAppStreamId, 0, 0, 0); + "Uio: User set SCTP AppStreamId [%hu].", parameters->data.sendAppStreamId, 0, 0, 0); return BSL_SUCCESS; } -static int32_t BslSctpSetPeerIpAddr(SctpParameters *parameters, const uint8_t *addr, uint32_t size) +static int32_t BslSctpSetPeerIpAddr(SctpParameters *parameters, const uint8_t *addr, int32_t size) { if (addr == NULL) { BSL_LOG_BINLOG_FIXLEN(BINLOG_ID05049, BSL_LOG_LEVEL_ERR, BSL_LOG_BINLOG_TYPE_RUN, @@ -138,7 +268,7 @@ static int32_t BslSctpSetPeerIpAddr(SctpParameters *parameters, const uint8_t *a } (void)memcpy_s(parameters->ip, sizeof(parameters->ip), addr, size); - parameters->ipLen = size; + parameters->ipLen = (uint32_t)size; return BSL_SUCCESS; } @@ -172,28 +302,21 @@ static int32_t BslSctpGetPeerIpAddr(SctpParameters *parameters, void *parg, int3 return BSL_SUCCESS; } -static int32_t BslSctpSetFd(BSL_UIO *uio, int32_t size, const int32_t *fd) +static int32_t BslSctpSetFd(BSL_UIO *uio, void *parg, int32_t larg) { - if (fd == NULL) { - BSL_ERR_PUSH_ERROR(BSL_NULL_INPUT); - return BSL_NULL_INPUT; - } - if (size != (int32_t)sizeof(*fd)) { + if (larg != (int32_t)sizeof(int32_t) || parg == NULL) { BSL_ERR_PUSH_ERROR(BSL_INVALID_ARG); return BSL_INVALID_ARG; } - SctpParameters *sctpCtx = BSL_UIO_GetCtx(uio); - if (sctpCtx == NULL) { - BSL_ERR_PUSH_ERROR(BSL_NULL_INPUT); - return BSL_NULL_INPUT; - } - if (sctpCtx->fd != -1) { + int32_t *fd = (int32_t *)parg; + SctpParameters *parameters = BSL_UIO_GetCtx(uio); + if (parameters->fd != -1) { if (BSL_UIO_GetIsUnderlyingClosedByUio(uio)) { - (void)BSL_SAL_SockClose(sctpCtx->fd); + (void)BSL_SAL_SockClose(parameters->fd); } } - sctpCtx->fd = *fd; - uio->init = 1; + parameters->fd = *fd; + uio->init = true; return BSL_SUCCESS; } @@ -221,210 +344,30 @@ static int32_t BslSctpMaskAppMsg(SctpParameters *parameters, void *parg, int32_t return BSL_SUCCESS; } -static bool BslSctpCheckPeerAuth(BSL_UIO *uio, void *parg, int32_t larg) +static int32_t BslSctpSetCtxCb(SctpParameters *parameters, int32_t type, void *func) { - if (parg == NULL || larg != sizeof(bool)) { - BSL_ERR_PUSH_ERROR(BSL_INVALID_ARG); - BSL_LOG_BINLOG_FIXLEN(BINLOG_ID05061, BSL_LOG_LEVEL_ERR, BSL_LOG_BINLOG_TYPE_RUN, - "check peer auth failed", 0, 0, 0, 0); - return BSL_INVALID_ARG; + if (parameters == NULL || func == NULL) { + BSL_ERR_PUSH_ERROR(BSL_NULL_INPUT); + return BSL_NULL_INPUT; } - int32_t fd = BSL_UIO_GetFd(uio); - if (fd < 0) { - BSL_ERR_PUSH_ERROR(BSL_UIO_IO_EXCEPTION); - return BSL_UIO_IO_EXCEPTION; - } - - int32_t optLen = (int32_t)sizeof(struct sctp_authchunks) + SCTP_GAUTH_CHUNKS_SIZE; - struct sctp_authchunks *auth = (struct sctp_authchunks*)BSL_SAL_Calloc(1u, optLen); - if (auth == NULL) { - BSL_ERR_PUSH_ERROR(BSL_MALLOC_FAIL); - return BSL_MALLOC_FAIL; - } - int32_t ret = BSL_SAL_GetSockopt(fd, IPPROTO_SCTP, SCTP_PEER_AUTH_CHUNKS, auth, &optLen); - if (ret != BSL_SUCCESS) { - BSL_SAL_Free(auth); - BSL_ERR_PUSH_ERROR(BSL_SAL_ERR_NET_GETSOCKOPT); - return BSL_SAL_ERR_NET_GETSOCKOPT; - } - bool dataChunkFlag = false; - bool forwardTsnChunkFlag = false; - for (uint32_t i = 0; i < auth->gauth_number_of_chunks; i++) { - if (auth->gauth_chunks[i] == SCTP_DATA_CHUNK_TYPE) { - dataChunkFlag = true; - } else if (auth->gauth_chunks[i] == SCTP_FORWARD_TSN_CHUNK_TYPE) { - forwardTsnChunkFlag = true; - } - } - if (dataChunkFlag && forwardTsnChunkFlag) { - *(bool *)parg = true; - } - BSL_SAL_Free(auth); - return BSL_SUCCESS; -} - -static int32_t AddAuthKey(BSL_UIO *uio, SctpParameters *parameters, struct sctp_authkey *auth, socklen_t optLen, - uint16_t prevShareKeyId) -{ - int32_t fd = BSL_UIO_GetFd(uio); - if (fd < 0) { - parameters->shareKeyId = prevShareKeyId; - BSL_ERR_PUSH_ERROR(BSL_UIO_IO_EXCEPTION); - return BSL_UIO_IO_EXCEPTION; - } - int32_t ret = BSL_SAL_SetSockopt(fd, IPPROTO_SCTP, SCTP_AUTH_KEY, auth, optLen); - if (ret != BSL_SUCCESS) { - parameters->shareKeyId = prevShareKeyId; - BSL_ERR_PUSH_ERROR(BSL_SAL_ERR_NET_SETSOCKOPT); - return BSL_SAL_ERR_NET_SETSOCKOPT; - } - parameters->isAddAuthkey = true; - parameters->prevShareKeyId = prevShareKeyId; - BSL_LOG_BINLOG_FIXLEN(BINLOG_ID05035, BSL_LOG_LEVEL_DEBUG, BSL_LOG_BINLOG_TYPE_RUN, - "Uio: SCTP Set auth key(id:%u) success.", parameters->shareKeyId, 0, 0, 0); - return BSL_SUCCESS; -} - -static int32_t BslSctpAddAuthKey(BSL_UIO *uio, void *parg, int32_t larg) -{ - if (parg == NULL || larg != sizeof(BSL_UIO_SctpAuthKey)) { - BSL_ERR_PUSH_ERROR(BSL_INVALID_ARG); - BSL_LOG_BINLOG_FIXLEN(BINLOG_ID05062, BSL_LOG_LEVEL_ERR, BSL_LOG_BINLOG_TYPE_RUN, - "add auth key failed", 0, 0, 0, 0); - return BSL_INVALID_ARG; - } - BSL_UIO_SctpAuthKey *key = (BSL_UIO_SctpAuthKey *)parg; - SctpParameters *parameters = (SctpParameters *)BSL_UIO_GetCtx(uio); - - if (parameters->isAddAuthkey) { - return BSL_SUCCESS; - } - - uint16_t prevShareKeyId = parameters->shareKeyId; - if (parameters->shareKeyId >= SCTP_SHARE_AUTHKEY_ID_MAX) { - parameters->shareKeyId = 1; - } else { - parameters->shareKeyId++; - } - key->shareKeyId = parameters->shareKeyId; - const uint8_t *authKey = key->authKey; - uint16_t size = key->authKeySize; - if (size != SCTP_SHARED_AUTHKEY_LEN) { - parameters->shareKeyId = prevShareKeyId; - BSL_ERR_PUSH_ERROR(BSL_UIO_IO_EXCEPTION); - return BSL_UIO_IO_EXCEPTION; - } - socklen_t optLen = sizeof(struct sctp_authkey) + SCTP_SHARED_AUTHKEY_LEN * sizeof(uint8_t); - struct sctp_authkey *auth = (struct sctp_authkey *)BSL_SAL_Calloc(1u, optLen); - if (auth == NULL) { - parameters->shareKeyId = prevShareKeyId; - BSL_ERR_PUSH_ERROR(BSL_MALLOC_FAIL); - return BSL_MALLOC_FAIL; - } - auth->sca_keylength = SCTP_SHARED_AUTHKEY_LEN; - auth->sca_keynumber = key->shareKeyId; - (void)memcpy_s(&auth->sca_key[0], SCTP_SHARED_AUTHKEY_LEN, authKey, size); - int32_t ret = AddAuthKey(uio, parameters, auth, optLen, prevShareKeyId); - BSL_SAL_Free(auth); - return ret; -} - -static int32_t CheckArgsAvalid(const void *parg, int32_t larg) -{ - if (parg == NULL || larg != sizeof(uint16_t)) { - BSL_ERR_PUSH_ERROR(BSL_INVALID_ARG); - BSL_LOG_BINLOG_FIXLEN(BINLOG_ID05063, BSL_LOG_LEVEL_ERR, BSL_LOG_BINLOG_TYPE_RUN, - "invalid args", 0, 0, 0, 0); - return BSL_INVALID_ARG; + switch (type) { + case BSL_UIO_WRITE_CB: + parameters->method.write = func; + break; + case BSL_UIO_READ_CB: + parameters->method.read = func; + break; + case BSL_UIO_CTRL_CB: + parameters->method.ctrl = func; + break; + default: + BSL_ERR_PUSH_ERROR(BSL_INVALID_ARG); + return BSL_INVALID_ARG; } return BSL_SUCCESS; } -static int32_t BslSctpActiveAuthKey(BSL_UIO *uio, void *parg, int32_t larg) -{ - int32_t ret = CheckArgsAvalid(parg, larg); - if (ret != BSL_SUCCESS) { - return ret; - } - SctpParameters *parameters = BSL_UIO_GetCtx(uio); - uint16_t shareKeyId = *(uint16_t*)parg; - /* Active shared key id */ - struct sctp_authkeyid authKeyId = {0}; - authKeyId.scact_keynumber = shareKeyId; - int32_t fd = BSL_UIO_GetFd(uio); - if (fd < 0) { - BSL_ERR_PUSH_ERROR(BSL_UIO_IO_EXCEPTION); - return BSL_UIO_IO_EXCEPTION; - } - ret = BSL_SAL_SetSockopt(fd, IPPROTO_SCTP, SCTP_AUTH_ACTIVE_KEY, &authKeyId, sizeof(struct sctp_authkeyid)); - if (ret != BSL_SUCCESS) { - BSL_ERR_PUSH_ERROR(BSL_SAL_ERR_NET_SETSOCKOPT); - return BSL_SAL_ERR_NET_SETSOCKOPT; - } - parameters->isAddAuthkey = false; - BSL_LOG_BINLOG_FIXLEN(BINLOG_ID05038, BSL_LOG_LEVEL_DEBUG, BSL_LOG_BINLOG_TYPE_RUN, - "Uio: SCTP active auth key(id:%u) success.", parameters->shareKeyId, 0, 0, 0); - - return BSL_SUCCESS; -} - -static int32_t BslSctpDelAuthKey(BSL_UIO *uio, void *parg, int32_t larg) -{ - int32_t ret = CheckArgsAvalid(parg, larg); - if (ret != BSL_SUCCESS) { - return ret; - } - uint16_t delShareKeyId = *(uint16_t*)parg; - int32_t fd = BSL_UIO_GetFd(uio); - if (fd < 0) { - BSL_ERR_PUSH_ERROR(BSL_UIO_IO_EXCEPTION); - return BSL_UIO_IO_EXCEPTION; - } - /* Delete old sharekey */ - struct sctp_authkeyid authKeyId = {0}; - authKeyId.scact_keynumber = delShareKeyId; - ret = BSL_SAL_SetSockopt(fd, IPPROTO_SCTP, SCTP_AUTH_DELETE_KEY, &authKeyId, sizeof(struct sctp_authkeyid)); - if (ret != BSL_SUCCESS) { - BSL_ERR_PUSH_ERROR(BSL_SAL_ERR_NET_SETSOCKOPT); - return BSL_SAL_ERR_NET_SETSOCKOPT; - } - return BSL_SUCCESS; -} - -static int32_t BslSctpIsSndBuffEmpty(BSL_UIO *uio, void *parg, int32_t larg) -{ - if (parg == NULL || larg != sizeof(uint8_t)) { - BSL_ERR_PUSH_ERROR(BSL_INVALID_ARG); - BSL_LOG_BINLOG_FIXLEN(BINLOG_ID05064, BSL_LOG_LEVEL_ERR, BSL_LOG_BINLOG_TYPE_RUN, - "get sctp status failed", 0, 0, 0, 0); - return BSL_INVALID_ARG; - } - - int32_t fd = BSL_UIO_GetFd(uio); - if (fd < 0) { - BSL_ERR_PUSH_ERROR(BSL_UIO_IO_EXCEPTION); - return BSL_UIO_IO_EXCEPTION; - } - - struct sctp_status status = {0}; - int32_t statusLen = sizeof(status); - int32_t ret = BSL_SAL_GetSockopt(fd, IPPROTO_SCTP, SCTP_STATUS, &status, &statusLen); - if (ret != BSL_SUCCESS) { - BSL_ERR_PUSH_ERROR(BSL_SAL_ERR_NET_GETSOCKOPT); - return BSL_SAL_ERR_NET_GETSOCKOPT; - } - - uint8_t *isEmpty = (uint8_t *)parg; - *isEmpty = false; - - if (status.sstat_unackdata == 0) { - *isEmpty = true; - } - - return BSL_SUCCESS; -} - -int32_t SctpCtrl(BSL_UIO *uio, int32_t cmd, int32_t larg, void *parg) +int32_t BslSctpCtrl(BSL_UIO *uio, int32_t cmd, int32_t larg, void *parg) { if (uio->ctx == NULL) { return BSL_NULL_INPUT; @@ -432,110 +375,54 @@ int32_t SctpCtrl(BSL_UIO *uio, int32_t cmd, int32_t larg, void *parg) SctpParameters *parameters = BSL_UIO_GetCtx(uio); switch (cmd) { case BSL_UIO_SET_PEER_IP_ADDR: - return BslSctpSetPeerIpAddr(parameters, parg, (uint32_t)larg); + return BslSctpSetPeerIpAddr(parameters, parg, larg); case BSL_UIO_GET_PEER_IP_ADDR: return BslSctpGetPeerIpAddr(parameters, parg, larg); - case BSL_UIO_SCTP_GET_SEND_STREAM_ID: - return BslSctpGetSendStreamId(uio, parg, larg); - case BSL_UIO_SCTP_SET_APP_STREAM_ID: - return BslSctpSetAppStreamId(parameters, parg, larg); case BSL_UIO_SET_FD: - return BslSctpSetFd(uio, larg, parg); + return BslSctpSetFd(uio, parg, larg); case BSL_UIO_GET_FD: return BslSctpGetFd(parameters, parg, larg); - case BSL_UIO_SCTP_MASK_APP_MESSAGE: - return BslSctpMaskAppMsg(parameters, parg, larg); - case BSL_UIO_SCTP_CHECK_PEER_AUTH: - return BslSctpCheckPeerAuth(uio, parg, larg); + case BSL_UIO_SCTP_GET_SEND_STREAM_ID: + return BslSctpGetSendStreamId(parameters, parg, larg); + case BSL_UIO_SCTP_SET_APP_STREAM_ID: + return BslSctpSetAppStreamId(parameters, parg, larg); case BSL_UIO_SCTP_ADD_AUTH_SHARED_KEY: + if (larg < 0 || larg > UINT16_MAX) { + break; + } return BslSctpAddAuthKey(uio, parg, larg); case BSL_UIO_SCTP_ACTIVE_AUTH_SHARED_KEY: - return BslSctpActiveAuthKey(uio, ¶meters->shareKeyId, sizeof(parameters->shareKeyId)); + return BslSctpActiveAuthKey(uio); case BSL_UIO_SCTP_DEL_PRE_AUTH_SHARED_KEY: - return BslSctpDelAuthKey(uio, ¶meters->prevShareKeyId, sizeof(parameters->shareKeyId)); + return BslSctpDelPreAuthKey(uio); + case BSL_UIO_SCTP_MASK_APP_MESSAGE: + return BslSctpMaskAppMsg(parameters, parg, larg); case BSL_UIO_SCTP_SND_BUFF_IS_EMPTY: return BslSctpIsSndBuffEmpty(uio, parg, larg); + case BSL_UIO_SCTP_SET_CALLBACK: + return BslSctpSetCtxCb(parameters, larg, parg); case BSL_UIO_FLUSH: return BSL_SUCCESS; default: - BSL_ERR_PUSH_ERROR(BSL_UIO_FAIL); - return BSL_UIO_FAIL; + break; } -} - -static int32_t SctpWrite(BSL_UIO *uio, const void *buf, uint32_t len, uint32_t *writeLen) -{ - /* set flags */ - const uint32_t flags = SCTP_SACK_IMMEDIATELY; - uint16_t sendStreamId = 0; - int32_t ret = BSL_UIO_Ctrl(uio, BSL_UIO_SCTP_GET_SEND_STREAM_ID, sizeof(sendStreamId), &sendStreamId); - if (ret != BSL_SUCCESS) { - return ret; - } - int32_t fd = BSL_UIO_GetFd(uio); - if (fd < 0) { - BSL_ERR_PUSH_ERROR(BSL_UIO_IO_EXCEPTION); - return BSL_UIO_IO_EXCEPTION; - } - ret = sctp_sendmsg(fd, buf, len, NULL, 0, 0, flags, sendStreamId, 0, 0); - if (ret <= 0) { - BSL_ERR_PUSH_ERROR(BSL_UIO_IO_EXCEPTION); - return BSL_UIO_IO_EXCEPTION; - } - *writeLen = ret; - - return BSL_SUCCESS; -} - -static int32_t SctpRead(BSL_UIO *uio, void *buf, uint32_t len, uint32_t *readLen) -{ - *readLen = 0; - SctpParameters *parameters = BSL_UIO_GetCtx(uio); - if (parameters == NULL) { - BSL_ERR_PUSH_ERROR(BSL_NULL_INPUT); - return BSL_NULL_INPUT; - } - - if (BSL_UIO_Ctrl(uio, BSL_UIO_SCTP_CHECK_PEER_AUTH, sizeof(parameters->peerAuthed), ¶meters->peerAuthed) != - BSL_SUCCESS || - parameters->peerAuthed == false) { - BSL_LOG_BINLOG_FIXLEN(BINLOG_ID05032, BSL_LOG_LEVEL_DEBUG, BSL_LOG_BINLOG_TYPE_RUN, - "Uio:Check SCTP Peer Auth ERROR.", 0, 0, 0, 0); - BSL_ERR_PUSH_ERROR(BSL_UIO_IO_EXCEPTION); - return BSL_UIO_IO_EXCEPTION; - } - - struct sctp_sndrcvinfo sinfo; - int32_t flags = 0; - int32_t fd = BSL_UIO_GetFd(uio); - if (fd < 0) { - BSL_ERR_PUSH_ERROR(BSL_UIO_IO_EXCEPTION); - return BSL_UIO_IO_EXCEPTION; - } - int32_t ret = sctp_recvmsg(fd, buf, len, NULL, NULL, &sinfo, &flags); - if (ret <= 0) { - if (UioIsNonFatalErr(errno) == true) { - return BSL_SUCCESS; - } - BSL_ERR_PUSH_ERROR(BSL_UIO_IO_EXCEPTION); - return BSL_UIO_IO_EXCEPTION; - } - - *readLen = ret; - return BSL_SUCCESS; + BSL_ERR_PUSH_ERROR(BSL_INVALID_ARG); + BSL_LOG_BINLOG_FIXLEN(BINLOG_ID05069, BSL_LOG_LEVEL_ERR, BSL_LOG_BINLOG_TYPE_RUN, + "invalid args", 0, 0, 0, 0); + return BSL_INVALID_ARG; } const BSL_UIO_Method *BSL_UIO_SctpMethod(void) { static const BSL_UIO_Method method = { BSL_UIO_SCTP, - SctpWrite, - SctpRead, - SctpCtrl, + BslSctpWrite, + BslSctpRead, + BslSctpCtrl, NULL, NULL, - SctpNew, - SctpDestroy + BslSctpNew, + BslSctpDestroy }; return &method; } diff --git a/bsl/uio/src/uio_sctp.h b/bsl/uio/src/uio_sctp.h deleted file mode 100644 index 96b874b3..00000000 --- a/bsl/uio/src/uio_sctp.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file is part of the openHiTLS project. - * - * openHiTLS is licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#ifndef UIO_SCTP_H -#define UIO_SCTP_H - -#include "hitls_build.h" -#ifdef HITLS_BSL_UIO_SCTP - -#include "bsl_uio.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define DTLS_SCTP_SHARE_AUTHKEY_ID_MAX 65535 - -int32_t SctpWrite(BSL_UIO *uio, const void *buf, uint32_t len, uint32_t *writeLen); -int32_t SctpRead(BSL_UIO *uio, void *buf, uint32_t len, uint32_t *readLen); - -#ifdef __cplusplus -} -#endif - -#endif /* HITLS_BSL_UIO_SCTP */ - -#endif // UIO_SCTP_H - diff --git a/configure.py b/configure.py index b97d6c72..de7626e1 100644 --- a/configure.py +++ b/configure.py @@ -379,7 +379,7 @@ class CMakeGenerator: if lib_name == 'hitls_bsl': for item in macros: if item == '-DHITLS_BSL_UIO' or item == '-DHITLS_BSL_UIO_SCTP': - cmake += self._gen_cmd_cmake("target_link_libraries", "hitls_bsl-shared sctp " + str(self._args.securec_lib)) + cmake += self._gen_cmd_cmake("target_link_libraries", "hitls_bsl-shared " + str(self._args.securec_lib)) if item == '-DHITLS_BSL_SAL_DL': cmake += self._gen_cmd_cmake("target_link_libraries", "hitls_bsl-shared dl " + str(self._args.securec_lib)) if lib_name == 'hitls_crypto': diff --git a/docs/en/4_User Guide/1_Build and Installation Guide.md b/docs/en/4_User Guide/1_Build and Installation Guide.md index 211d5e7d..8e8efda8 100644 --- a/docs/en/4_User Guide/1_Build and Installation Guide.md +++ b/docs/en/4_User Guide/1_Build and Installation Guide.md @@ -11,8 +11,6 @@ Check whether the build tools have been installed in the system and can be used | CMake | ≥ 3.16 | Linux | | Sctp | No restriction on versions | Linux | -P.S. The DTLS feature depends on sctp. By default, sctp is disabled. To enable it, you need to pre-install sctp dependencies. - ## 2. Preparing the Source Code Method 1 @@ -83,7 +81,6 @@ openHiTLS provides the CMake build mode, which can be configured using **configu |--compile_config|Specifies the compilation parameter configuration file.|python3 configure.py --compile_config path/to/xxx.json| |--enable|Specifies build features.
Please refer to [Feature Description](./4_Configuration%20guide.md#1-Feature%20Description) to get supported features|python3 configure.py --enable hitls_crypto hitls_tls hitls_pse| |--disable|disable buld features|python3 configure.py --disable sal_thread | -|--enable-sctp|enable sctp which is DTLS depended on|python3 configure.py --enable-sctp| |--asm_type|Indicates the assembly type.|python3 configure.py --lib_type static --asm_type armv8| |--asm|Specifes build asm features, whicht needs to be used simultaneously with parameter `asm_type`.|python3 configure.py --lib_type static --asm_type armv8 --asm sha2| |--endian|Indicates big-endian or little-endian build.|python3 configure.py --endian little| @@ -119,9 +116,6 @@ python3 ../configure.py --disable [feature]::[module] # Enable a feature. python3 ../configure.py --enable [feature]::[module] -# Enable sctp -python3 ../configure.py --enable-sctp - # Default configuration file. If the file does not exist, a file is generated. Otherwise, no action is performed. python3 ../configure.py -m diff --git a/docs/zh/4_使用指南/1_构建及安装指导.md b/docs/zh/4_使用指南/1_构建及安装指导.md index 1f375ae2..d882c2cd 100644 --- a/docs/zh/4_使用指南/1_构建及安装指导.md +++ b/docs/zh/4_使用指南/1_构建及安装指导.md @@ -81,7 +81,6 @@ openHiTLS提供CMake构建方式,可通过configure.py进行配置,之后建 |--compile_config|指定编译参数配置文件|python3 configure.py --compile_config path/to/xxx.json| |--enable|指定构建特性
请参考[特性说明](./4_配置指南.md#1-特性说明)获取支持的特性|python3 configure.py --enable hitls_crypto hitls_tls hitls_pse| |--disable|关闭构建特性|python3 configure.py --disable sal_thread | -|--enable-sctp|开启sctp编译, DTLS依赖sctp|python3 configure.py --enable-sctp| |--asm_type|汇编类型|python3 configure.py --lib_type static --asm_type armv8| |--asm|指定汇编特性,需要与`asm_type`同时使用|python3 configure.py --lib_type static --asm_type armv8 --asm sha2| |--endian|大小端构建|python3 configure.py --endian little| @@ -117,9 +116,6 @@ python3 ../configure.py --disable [feature]::[module] # 开启某个特性 python3 ../configure.py --enable [feature]::[module] -# 开启sctp -python3 ../configure.py --enable-sctp - # 默认配置,当文件不存在时,则生成文件,否则没有任何动作 python3 ../configure.py -m diff --git a/include/bsl/bsl_uio.h b/include/bsl/bsl_uio.h index 9c71e7b4..16578814 100644 --- a/include/bsl/bsl_uio.h +++ b/include/bsl/bsl_uio.h @@ -132,7 +132,7 @@ typedef enum { BSL_UIO_SCTP_GET_SEND_STREAM_ID, BSL_UIO_SCTP_SET_APP_STREAM_ID, BSL_UIO_SCTP_MASK_APP_MESSAGE, - + BSL_UIO_SCTP_SET_CALLBACK, /* MEM uses 0x4XX */ BSL_UIO_MEM_NEW_BUF = 0x400, BSL_UIO_MEM_GET_PTR, diff --git a/testcode/framework/process/CMakeLists.txt b/testcode/framework/process/CMakeLists.txt index df59c69f..eff21da2 100644 --- a/testcode/framework/process/CMakeLists.txt +++ b/testcode/framework/process/CMakeLists.txt @@ -49,6 +49,6 @@ if(ENABLE_PKI AND ${BUILD_PKI} GREATER -1) list(APPEND PROCESS_LIBS hitls_pki) endif() -list(APPEND PROCESS_LIBS hitls_crypto hitls_bsl boundscheck pthread dl sctp rec_wrapper) +list(APPEND PROCESS_LIBS hitls_crypto hitls_bsl boundscheck pthread dl rec_wrapper) target_link_libraries(process ${PROCESS_LIBS}) diff --git a/testcode/framework/tls/rpc/include/rpc_func.h b/testcode/framework/tls/rpc/include/rpc_func.h index 93036bad..fb53b985 100644 --- a/testcode/framework/tls/rpc/include/rpc_func.h +++ b/testcode/framework/tls/rpc/include/rpc_func.h @@ -164,10 +164,6 @@ int RpcTlsClose(CmdData *cmdData); */ int RpcFreeResFormSsl(CmdData *cmdData); -/** -* @brief RPC Disable the SCTP connection. -*/ -int RpcSctpClose(CmdData *cmdData); int RpcCloseFd(CmdData *cmdData); diff --git a/testcode/framework/tls/rpc/src/hitls_func.c b/testcode/framework/tls/rpc/src/hitls_func.c index 5fee2784..992aa5bb 100644 --- a/testcode/framework/tls/rpc/src/hitls_func.c +++ b/testcode/framework/tls/rpc/src/hitls_func.c @@ -692,8 +692,6 @@ void HitlsFreeSsl(void *ssl) const BSL_UIO_Method *GetDefaultMethod(HILT_TransportType type) { switch (type) { - case SCTP: - return SctpGetDefaultMethod(); case TCP: return TcpGetDefaultMethod(); case UDP: @@ -707,7 +705,6 @@ const BSL_UIO_Method *GetDefaultMethod(HILT_TransportType type) int HitlsSetSsl(void *ssl, HLT_Ssl_Config *sslConfig) { int ret; - SetNeedCbSctpCtrlCmd(sslConfig->sctpCtrlCmd); if (sslConfig->SupportType == SERVER_CTX_SET_TRUE) { HITLS_SetCipherServerPreference((HITLS_Ctx *)ssl, true); } diff --git a/testcode/framework/tls/rpc/src/hlt_func.c b/testcode/framework/tls/rpc/src/hlt_func.c index e89a47c9..19a9bd55 100644 --- a/testcode/framework/tls/rpc/src/hlt_func.c +++ b/testcode/framework/tls/rpc/src/hlt_func.c @@ -400,7 +400,6 @@ int RunDataChannelBind(void *param) LOG_DEBUG("RunDataChannelBind Ing...\n"); DataChannelParam *channelParam = (DataChannelParam*)param; switch (channelParam->type) { - case SCTP: sockFd = SctpBind(channelParam->port); break; case TCP: sockFd = TcpBind(channelParam->port); break; case UDP: sockFd = UdpBind(channelParam->port); break; default: @@ -421,9 +420,6 @@ int RunDataChannelAccept(void *param) LOG_DEBUG("RunDataChannelAccept Ing...\n"); DataChannelParam *channelParam = (DataChannelParam *)param; switch (channelParam->type) { - case SCTP: - sockFd = SctpAccept(channelParam->ip, channelParam->bindFd, channelParam->isBlock); - break; case TCP: sockFd = TcpAccept(channelParam->ip, channelParam->bindFd, channelParam->isBlock, true); break; @@ -456,7 +452,6 @@ int HLT_DataChannelBind(DataChannelParam *channelParam) int HLT_DataChannelConnect(DataChannelParam *dstChannelParam) { switch (dstChannelParam->type) { - case SCTP: return SctpConnect(dstChannelParam->ip, dstChannelParam->port, dstChannelParam->isBlock); case TCP: return TcpConnect(dstChannelParam->ip, dstChannelParam->port); case UDP: return UdpConnect(dstChannelParam->ip, dstChannelParam->port); default: @@ -529,7 +524,6 @@ void HLT_CloseFd(int fd, int linkType) { switch (linkType) { case TCP: TcpClose(fd); break; - case SCTP: SctpClose(fd); break; case UDP: UdpClose(fd); break; default: /* Unknown fd type */ @@ -1362,22 +1356,7 @@ void HLT_CleanFrameHandle(void) CleanFrameHandle(); } -#define SCTP_AUTH_FILE_PATH "/proc/sys/net/sctp/auth_enable" -#define SCTP_AUTH_ENABLE "echo 1 > /proc/sys/net/sctp/auth_enable" -#define SCTP_FLAG_BUFF 10 - bool IsEnableSctpAuth(void) { - system(SCTP_AUTH_ENABLE); - char buf[SCTP_FLAG_BUFF] = { 0 }; - FILE* file = fopen(SCTP_AUTH_FILE_PATH, "r+"); - if (file == NULL) { - return false; - } - (void)fgets(buf, SCTP_FLAG_BUFF, file); - fclose(file); - if (strcmp(buf, "1\n") == 0) { - return true; - } return false; } diff --git a/testcode/framework/tls/rpc/src/rpc_func.c b/testcode/framework/tls/rpc/src/rpc_func.c index 2b0f79d1..ce7c6bfa 100644 --- a/testcode/framework/tls/rpc/src/rpc_func.c +++ b/testcode/framework/tls/rpc/src/rpc_func.c @@ -68,7 +68,6 @@ RpcFunList g_rpcFuncList[] = { {"HLT_RpcTlsGetAlertDescription", RpcTlsGetAlertDescription}, {"HLT_RpcTlsClose", RpcTlsClose}, {"HLT_RpcFreeResFormSsl", RpcFreeResFormSsl}, - {"HLT_RpcSctpClose", RpcSctpClose}, {"HLT_RpcCloseFd", RpcCloseFd}, {"HLT_RpcTlsSetMtu", RpcTlsSetMtu}, {"HLT_RpcTlsGetErrorCode", RpcTlsGetErrorCode}, @@ -722,22 +721,6 @@ int RpcFreeResFormSsl(CmdData *cmdData) return SUCCESS; } -int RpcSctpClose(CmdData *cmdData) -{ - int ret, fd; - char *endPtr = NULL; - - ASSERT_RETURN(memset_s(cmdData->result, sizeof(cmdData->result), 0, sizeof(cmdData->result)) == EOK); - fd = (int)strtol(cmdData->paras[0], &endPtr, 0); - - SctpClose(fd); - - // Return the result - ret = sprintf_s(cmdData->result, sizeof(cmdData->result), "%s|%s|%d", cmdData->id, cmdData->funcId, SUCCESS); - ASSERT_RETURN(ret > 0); - return SUCCESS; -} - int RpcCloseFd(CmdData *cmdData) { int ret, fd, linkType; diff --git a/testcode/framework/tls/transfer/src/sctp_channel.c b/testcode/framework/tls/transfer/src/sctp_channel.c deleted file mode 100644 index 02af8ccc..00000000 --- a/testcode/framework/tls/transfer/src/sctp_channel.c +++ /dev/null @@ -1,446 +0,0 @@ -/* - * This file is part of the openHiTLS project. - * - * openHiTLS is licensed under the Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, - * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, - * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "securec.h" -#include "logger.h" -#include "hitls_error.h" -#include "hitls_type.h" -#include "hitls.h" -#include "tls.h" -#include "hs_ctx.h" -#include "bsl_errno.h" -#include "uio_base.h" -#include "hlt_type.h" -#include "socket_common.h" -#include "bsl_uio.h" -#include "uio_abstraction.h" -#define SUCCESS 0 -#define ERROR (-1) - -#define SCTP_DATA_CHUNK_TYPE 0x00 -#define SCTP_FORWARD_TSN_CHUNK_TYPE 0xc0 -#define SCTP_LISTEN_MAX 5 -#define SCTP_GAUTH_CHUNKS_SIZE 256 -#define SCTP_AUTH_ENABLE "echo 1 > /proc/sys/net/sctp/auth_enable" - -int g_NeedCbsctpCtrlCmd; -int32_t SctpCtrl(BSL_UIO *uio, int32_t cmd, int32_t larg, void *parg); - -/* -To enable the RFC 4895 about authenticating chunks: -$ sudo echo 1 > /proc/sys/net/sctp/auth_enable -To enable the RFC 5061 about dynamic address reconfiguration: -$ sudo echo 1 > /proc/sys/net/sctp/addip_enable -You may also want to use the dynamic address reconfiguration without necessarily enabling the chunk authentication: -$ sudo echo 1 > /proc/sys/net/sctp/addip_noauth_enable -*/ -int32_t SctpEnableAuth(int32_t fd) -{ - /* To enable the RFC 4895 authentication block */ - system(SCTP_AUTH_ENABLE); - /* data chunks */ - struct sctp_authchunk auth; - auth.sauth_chunk = SCTP_DATA_CHUNK_TYPE; - int32_t ret = setsockopt(fd, IPPROTO_SCTP, SCTP_AUTH_CHUNK, &auth, sizeof(struct sctp_authchunk)); - if (ret < 0) { - LOG_ERROR("error while setsockopt SCTP_AUTH_CHUNK. ret is %d\n", ret); - return ERROR; - } - /* FORWARD-TSN chunks */ - auth.sauth_chunk = SCTP_FORWARD_TSN_CHUNK_TYPE; - ret = setsockopt(fd, IPPROTO_SCTP, SCTP_AUTH_CHUNK, &auth, - sizeof(struct sctp_authchunk)); - if (ret < 0) { - LOG_ERROR("error while setsockopt SCTP_AUTH_CHUNK. ret is %d\n", ret); - return ERROR; - } - LOG_DEBUG("SctpEnableAuth Success"); - return SUCCESS; -} - -/* Obtain the number of transmitted streams */ -static int32_t SctpGetSendStreamNum(int32_t fd, uint16_t *sendStreamNum) -{ - struct sctp_status status; - socklen_t statusLen = sizeof(status); - int32_t ret = getsockopt(fd, IPPROTO_SCTP, SCTP_STATUS, &status, &statusLen); - if (ret < 0) { - LOG_ERROR("error while geting socket option.\n"); - return ret; - } - *sendStreamNum = status.sstat_outstrms; - return 0; -} - -/* Connects to the peer and returns a socket descriptor. - Currently, only one IP function is designed. If required, SCTP_Connect can be rewritten. - */ -int32_t SctpConnect(char *targetIP, int targetPort, bool isBlock) -{ - (void)targetIP; - int32_t fd = 0; - int32_t ret; - struct sockaddr_in sockAddr; - // Create a socket - if ((fd = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP)) == -1) { - LOG_ERROR("Create Sock Fail"); - return ERROR; - } - - int32_t option = 1; - if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option)) < 0) { - LOG_ERROR("Set Sock Opt Fail"); - goto ERR; - } - - struct linger so_linger; - so_linger.l_onoff = true; - so_linger.l_linger = 0; - if (setsockopt(fd, SOL_SOCKET, SO_LINGER, &so_linger, sizeof(so_linger)) < 0) { - close(fd); - LOG_ERROR("setsockopt() linger fail\n"); - return -1; - } - - /* Enable SCTP auth */ - ret = SctpEnableAuth(fd); - if (ret != 0) { - LOG_ERROR("SctpEnableAuth."); - goto ERR; - } - - /* Enable SCTP Events */ - struct sctp_event_subscribe events = {0}; - events.sctp_data_io_event = 1; - ret = setsockopt(fd, SOL_SCTP, SCTP_EVENTS, (void *)&events, sizeof(events)); - if (ret < 0) { - LOG_ERROR("setsockopt SCTP_EVENTS."); - goto ERR; - } - - // Set the protocol and port number - bzero(&sockAddr, sizeof(struct sockaddr_in)); - sockAddr.sin_family = AF_INET; - sockAddr.sin_port = htons(targetPort); - // Set the IP address - sockAddr.sin_addr.s_addr = inet_addr("127.0.0.1"); - - // Connection - int16_t tryNum = 0; - sctp_assoc_t assoc_id; - LOG_DEBUG("Try Sctp Connect..."); - do { - ret = sctp_connectx(fd, (struct sockaddr*)&sockAddr, 1, &assoc_id); - tryNum++; - usleep(1000); // 1000microseconds - } while ((ret != 0) && (tryNum < 6000)); // 6000 indicates that the connection is attempted within 6 seconds - if (ret != 0) { - LOG_ERROR("Sctp Connect Fail, ret is %d error id: %d\n", ret, errno); - goto ERR; - } - LOG_DEBUG("SCTP Connect Success"); - uint16_t sendStreamNum; - ret = SctpGetSendStreamNum(fd, &sendStreamNum); - if (ret != 0) { - LOG_ERROR("SctpGetSendStreamNum error."); - goto ERR; - } - // Whether to set the blocking interface - ret = SetBlockMode(fd, isBlock); - return fd; - -ERR: - close(fd); - return ERROR; -} - -int32_t SctpBind(int port) -{ - int32_t lisentFd; - struct sockaddr_in serverAddr; - int32_t ret; - - // Create a socket - lisentFd = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP); - if (lisentFd == -1) { - LOG_ERROR("create socket() fail."); - return ERROR; - } - - int32_t option = 1; - if (setsockopt(lisentFd, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option)) < 0) { - LOG_ERROR("setsockopt fail."); - goto ERR; - } - - struct linger so_linger; - so_linger.l_onoff = true; - so_linger.l_linger = 0; - if (setsockopt(lisentFd, SOL_SOCKET, SO_LINGER, &so_linger, sizeof(so_linger)) < 0) { - close(lisentFd); - LOG_ERROR("setsockopt() linger fail\n"); - return -1; - } - - // Set the protocol and port number - bzero(&serverAddr, sizeof(serverAddr)); - serverAddr.sin_family = AF_INET; - serverAddr.sin_port = htons(port); - serverAddr.sin_addr.s_addr = htonl(INADDR_ANY); - - const int32_t addr_count = 1; - int32_t tryNum = 0; - // Bind fails. Continue to bind - LOG_DEBUG("Bind Ing..."); - do { - ret = sctp_bindx(lisentFd, (struct sockaddr*)&serverAddr, addr_count, SCTP_BINDX_ADD_ADDR); - usleep(1000); // 1000 microseconds, that is, 1 ms - tryNum++; - } while ((ret != 0) && (tryNum < 6000)); // 6000: indicates that the binding attempt is 6 seconds - if (ret != 0) { - LOG_ERROR("sctp_bindx socket fail error id: %d\n", errno); - goto ERR; - } - LOG_DEBUG("SCTP BIND SUCCESS"); - /* Enable SCTP auth */ - ret = SctpEnableAuth(lisentFd); - if (ret == ERROR) { - LOG_ERROR("SctpEnableAuth Error"); - goto ERR; - } - - /* Enable SCTP Events */ - struct sctp_event_subscribe events = {0}; - events.sctp_data_io_event = 1; - ret = setsockopt(lisentFd, SOL_SCTP, SCTP_EVENTS, (void *)&events, sizeof(events)); - if (ret < 0) { - LOG_ERROR("setsockopt SCTP_EVENTS error."); - goto ERR; - } - - if (listen(lisentFd, SCTP_LISTEN_MAX) != 0) { - LOG_ERROR("listen socket fail, error id is %d\n", errno); - goto ERR; - } - - return lisentFd; - -ERR: - close(lisentFd); - return ERROR; -} - -int32_t SctpAccept(char* ip, int listenFd, bool isBlock) -{ - (void)ip; - int32_t ret; - struct sockaddr_in sockAddr; - - uint32_t len = sizeof(struct sockaddr_in); - int32_t fd; - uint32_t tryNum; - tryNum = 0; - do { - fd = accept(listenFd, (struct sockaddr *)&sockAddr, &len); - tryNum++; - usleep(1000); // 1000 microseconds, that is, 1 ms - // 10000: indicates that the system attempts to listen on the system for 10 seconds - } while ((fd < 0) && (tryNum < 10000)); - if (fd < 0) { - LOG_ERROR("SCTP Accept Fail, error id is %d\n", errno); - close(listenFd); - return ERROR; - } - - LOG_DEBUG("SCTP Accept Success"); - uint16_t sendStreamNum; - ret = SctpGetSendStreamNum(fd, &sendStreamNum); - if (ret != 0) { - LOG_ERROR("SctpGetSendStreamNum error."); - close(listenFd); - close(fd); - return ERROR; - } - - // Indicates whether to block the interface - ret = SetBlockMode(fd, isBlock); - if (ret != SUCCESS) { - close(listenFd); - close(fd); - LOG_ERROR("SetBlockMode ERROR"); - } - // Disable listenFd - close(listenFd); - return fd; -} - -/* closes the given socket descriptor. */ -void SctpClose(int32_t fd) -{ - close(fd); -} - -void SetNeedCbSctpCtrlCmd(int cmd) -{ - g_NeedCbsctpCtrlCmd = cmd; -} - - - -int32_t SctpFrameWrite(BSL_UIO *uio, const void *buf, uint32_t len, uint32_t *writeLen) -{ - int32_t ret; - uint8_t *newBuf = NULL; - const void *sendBuf = buf; - uint32_t sendLen = len; - HLT_FrameHandle *frameHandle = GetFrameHandle(); - - if (frameHandle->frameCallBack != NULL && frameHandle->pointType == POINT_SEND) { - newBuf = GetNewBuf(buf, len, &sendLen); - if (sendLen == 0) { // when sendLen changes and becomes 0, the value is IO_BUSY - *writeLen = 0; - return BSL_SUCCESS; - } - if (newBuf != NULL) { - sendBuf = (void *)newBuf; - } - } - ret = BSL_UIO_SctpMethod()->write(uio, sendBuf, sendLen, writeLen); - if (sendLen != len && *writeLen != 0) { - *writeLen = len; - } - FreeNewBuf(newBuf); - return ret; -} - -int32_t SctpFrameRead(BSL_UIO *uio, void *buf, uint32_t len, uint32_t *readLen) -{ - int ret; - ret = BSL_UIO_SctpMethod()->read(uio, buf, len, readLen); - if (ret != BSL_SUCCESS) { - return ret; - } - - uint8_t *newBuf = NULL; - uint32_t packLen = *readLen; - HLT_FrameHandle *frameHandle = GetFrameHandle(); - if (frameHandle->frameCallBack != NULL && frameHandle->pointType == POINT_RECV) { - newBuf = GetNewBuf(buf, len, &packLen); - if (packLen == 0) { // when packLen changes and becomes 0, the value is IO_BUSY - *readLen = 0; - return BSL_SUCCESS; - } - if (newBuf != NULL) { - if (memcpy_s(buf, len, (uint8_t *)newBuf, packLen) != EOK) { - FreeNewBuf(newBuf); - return BSL_UIO_IO_EXCEPTION; - } - *readLen = packLen; - } - FreeNewBuf(newBuf); - } - return BSL_SUCCESS; -} - -int32_t SelectSctpWrite(BSL_UIO *uio, const void *buf, uint32_t len, uint32_t *writeLen) -{ - HLT_FrameHandle *frameHandle = GetFrameHandle(); - if (frameHandle->method.write != NULL) { - return frameHandle->method.write(uio, buf, len, writeLen); - } - return SctpFrameWrite(uio, buf, len, writeLen); -} - -int32_t SelectSctpRead(BSL_UIO *uio, void *buf, uint32_t len, uint32_t *readLen) -{ - HLT_FrameHandle *frameHandle = GetFrameHandle(); - if (frameHandle->method.read != NULL) { - return frameHandle->method.read(uio, buf, len, readLen); - } - return SctpFrameRead(uio, buf, len, readLen); -} - -int32_t SelectSctpCtrl(BSL_UIO *uio, int32_t cmd, int32_t larg, void *param) -{ - HLT_FrameHandle *frameHandle = GetFrameHandle(); - if (frameHandle->method.ctrl != NULL) { - return frameHandle->method.ctrl(uio, cmd, larg, param); - } - return BSL_UIO_SctpMethod()->ctrl(uio, cmd, larg, param); -} - -static BSL_UIO_Method g_SctpUioMethodDefault; - -/* Provide the default Linux implementation method */ -BSL_UIO_Method *SctpGetDefaultMethod(void) -{ - const BSL_UIO_Method *ori = BSL_UIO_SctpMethod(); - memcpy(&g_SctpUioMethodDefault, ori, sizeof(g_SctpUioMethodDefault)); - g_SctpUioMethodDefault.write = SelectSctpWrite; - g_SctpUioMethodDefault.read = SelectSctpRead; - g_SctpUioMethodDefault.ctrl = SelectSctpCtrl; - return &g_SctpUioMethodDefault; -} - -/** - * @brief Implement the write interface, specifying whether the flow is out of order and the flow ID - * - * @param uio [IN] the point to the UIO. - * @param buf [IN] Transmitted data - * @param len [IN] Send length - * @param writeLen [IN] Length of the successfully sent message - * @return BSL_SUCCESS succeeded - BSL_UIO_FAIL failure - BSL_UIO_IO_EXCEPTION IOexception - */ -int32_t SctpDefaultWrite(BSL_UIO *uio, const void *buf, uint32_t len, uint32_t *writeLen) -{ - /* set flags */ - // is set to SCTP_UNORD:00-20:00, the messages are sent in disorder. - // Whether the messages are sent in disorder is defined by the user - const uint32_t flags = SCTP_SACK_IMMEDIATELY; - uint16_t sendStreamId = 0; - int32_t ret = uio->method.ctrl(uio, BSL_UIO_SCTP_GET_SEND_STREAM_ID, sizeof(sendStreamId), &sendStreamId); - if (ret != BSL_SUCCESS) { - LOG_ERROR("error: get sctp send stream id fail %d", ret); - return ret; - } - int32_t fd = BSL_UIO_GetFd(uio); - if (fd < 0) { - LOG_ERROR("error: get fd fail"); - return BSL_UIO_IO_EXCEPTION; - } - ret = sctp_sendmsg(fd, buf, len, NULL, 0, 0, flags, sendStreamId, 0, 0); - if (ret < 0) { - /* Fatal error */ - LOG_ERROR("SCTP ERROR IS %d", errno); - return BSL_UIO_IO_EXCEPTION; - } else if (ret == 0) { - return BSL_UIO_IO_EXCEPTION; - } - *writeLen = ret; - - return BSL_SUCCESS; -} \ No newline at end of file diff --git a/testcode/sdv/CMakeLists.txt b/testcode/sdv/CMakeLists.txt index 0528b2c8..8999977b 100644 --- a/testcode/sdv/CMakeLists.txt +++ b/testcode/sdv/CMakeLists.txt @@ -58,10 +58,6 @@ endif() list(APPEND TEST_INTF_LIBS hitls_bsl boundscheck pthread dl) -if(ENABLE_UIO_SCTP OR (ENABLE_TLS AND ${BUILD_TLS} GREATER -1)) - list(APPEND TEST_INTF_LIBS sctp) -endif() - target_link_libraries(TEST_INTF INTERFACE ${TEST_INTF_LIBS}) target_include_directories(TEST_INTF diff --git a/testcode/sdv/testcase/bsl/uio/test_suite_sdv_uio.c b/testcode/sdv/testcase/bsl/uio/test_suite_sdv_uio.c index aec9eab1..05f796d4 100644 --- a/testcode/sdv/testcase/bsl/uio/test_suite_sdv_uio.c +++ b/testcode/sdv/testcase/bsl/uio/test_suite_sdv_uio.c @@ -37,7 +37,6 @@ #include "bsl_uio.h" #include "uio_base.h" #include "uio_local.h" -#include "uio_sctp.h" #include "uio_udp.h" #include "sal_atomic.h" #include "uio_abstraction.h" @@ -119,10 +118,6 @@ const BSL_UIO_Method * GetUioMethodByType(int uioType) switch (uioType) { case BSL_UIO_TCP: return BSL_UIO_TcpMethod(); -#ifdef HITLS_BSL_UIO_SCTP - case BSL_UIO_SCTP: - return BSL_UIO_SctpMethod(); -#endif case BSL_UIO_UDP: return BSL_UIO_UdpMethod(); case BSL_UIO_BUFFER: @@ -258,20 +253,6 @@ void SDV_BSL_UIO_NEW_API_TC001(void) /* Set method to NULL */ BSL_UIO *uio = BSL_UIO_New(NULL); ASSERT_TRUE(uio == NULL); -#ifdef HITLS_BSL_UIO_SCTP - /* Set transportType to sctp and construct a method structure. */ - { - const BSL_UIO_Method *ori = BSL_UIO_SctpMethod(); - BSL_UIO_Method method = {0}; - memcpy(&method, ori, sizeof(method)); - method.write = STUB_Write; - method.read = STUB_Read; - method.ctrl = STUB_Ctrl; - uio = BSL_UIO_New(&method); - ASSERT_TRUE(uio != NULL && BSL_UIO_GetTransportType(uio) == BSL_UIO_SCTP); - BSL_UIO_Free(uio); - } -#endif /* Set transportType to tcp and construct the method structure. */ { const BSL_UIO_Method *ori = BSL_UIO_TcpMethod(); @@ -435,13 +416,6 @@ void SDV_BSL_UIO_INIT_FUNC_TC001(int uioType) case BSL_UIO_UDP: ori = GetUioMethodByType(uioType); break; - case BSL_UIO_SCTP: -#ifdef HITLS_BSL_UIO_SCTP - ori = GetUioMethodByType(uioType); -#else - SKIP_TEST(); -#endif - break; default: // The uio of the FD cannot be set. ASSERT_TRUE(false); } @@ -616,11 +590,6 @@ EXIT: /* BEGIN_CASE */ void SDV_BSL_UIO_FLAGS_FUNC_TC001(int uioType) { - if (uioType == BSL_UIO_SCTP) { -#ifndef HITLS_BSL_UIO_SCTP - SKIP_TEST(); -#endif - } BSL_UIO *uio = NULL; const BSL_UIO_Method *ori = GetUioMethodByType(uioType); diff --git a/testcode/sdv/testcase/bsl/uio/test_suite_sdv_uio.data b/testcode/sdv/testcase/bsl/uio/test_suite_sdv_uio.data index 4bdabc47..50e9f151 100644 --- a/testcode/sdv/testcase/bsl/uio/test_suite_sdv_uio.data +++ b/testcode/sdv/testcase/bsl/uio/test_suite_sdv_uio.data @@ -13,9 +13,6 @@ SDV_BSL_UIO_INIT_FUNC_TC001:BSL_UIO_TCP SDV_BSL_UIO_INIT_FUNC_TC001 BSL_UIO_UDP SDV_BSL_UIO_INIT_FUNC_TC001:BSL_UIO_UDP -SDV_BSL_UIO_INIT_FUNC_TC001 BSL_UIO_SCTP -SDV_BSL_UIO_INIT_FUNC_TC001:BSL_UIO_SCTP - SDV_BSL_UIO_INIT_FUNC_TC002 BSL_UIO_BUFFER SDV_BSL_UIO_INIT_FUNC_TC002:BSL_UIO_BUFFER @@ -34,9 +31,6 @@ SDV_BSL_UIO_FLAGS_FUNC_TC001:BSL_UIO_TCP uio flags test: BSL_UIO_UDP SDV_BSL_UIO_FLAGS_FUNC_TC001:BSL_UIO_UDP -uio flags test: BSL_UIO_SCTP -SDV_BSL_UIO_FLAGS_FUNC_TC001:BSL_UIO_SCTP - uio flags test: BSL_UIO_BUFFER SDV_BSL_UIO_FLAGS_FUNC_TC001:BSL_UIO_BUFFER diff --git a/testcode/sdv/testcase/tls/consistency/dtlcp/test_suite_sdv_frame_dtlcp_consistency.base.c b/testcode/sdv/testcase/tls/consistency/dtlcp/test_suite_sdv_frame_dtlcp_consistency.base.c index eaeaf67e..1da1e1f8 100644 --- a/testcode/sdv/testcase/tls/consistency/dtlcp/test_suite_sdv_frame_dtlcp_consistency.base.c +++ b/testcode/sdv/testcase/tls/consistency/dtlcp/test_suite_sdv_frame_dtlcp_consistency.base.c @@ -134,7 +134,7 @@ int32_t DefaultCfgStatusParkWithSuite(HandshakeTestInfo *testInfo) testInfo->config->isSupportClientVerify = testInfo->isSupportClientVerify; testInfo->config->isSupportNoClientCert = testInfo->isSupportNoClientCert; - return StatusPark(testInfo, BSL_UIO_SCTP); + return StatusPark(testInfo, BSL_UIO_UDP); } int32_t SendHelloReqWithIndex(HITLS_Ctx *ctx, uint8_t index) @@ -337,7 +337,7 @@ int32_t DefaultCfgStatusPark1(HandshakeTestInfo *testInfo) HITLS_CFG_SetClientVerifySupport(testInfo->config, testInfo->isSupportClientVerify); HITLS_CFG_SetNoClientCertSupport(testInfo->config, false); HITLS_CFG_SetExtenedMasterSecretSupport(testInfo->config, true); - return StatusPark(testInfo, BSL_UIO_SCTP); + return StatusPark(testInfo, BSL_UIO_UDP); } static int32_t GetRepeatsApp(FRAME_LinkObj *obj, uint8_t *data, uint32_t *usedLen) diff --git a/testcode/sdv/testcase/tls/consistency/dtlcp/test_suite_sdv_frame_dtlcp_consistency.c b/testcode/sdv/testcase/tls/consistency/dtlcp/test_suite_sdv_frame_dtlcp_consistency.c index 993c280e..62c4d47c 100644 --- a/testcode/sdv/testcase/tls/consistency/dtlcp/test_suite_sdv_frame_dtlcp_consistency.c +++ b/testcode/sdv/testcase/tls/consistency/dtlcp/test_suite_sdv_frame_dtlcp_consistency.c @@ -17,52 +17,6 @@ /* INCLUDE_BASE test_suite_sdv_frame_dtlcp_consistency */ /* END_HEADER */ - -/* @ -* @test UT_TLS_DTLCP_CONSISTENCY_RFC6083_RETRANSMISSION_TC001 -* @spec - -* @title Check that DTLCP over SCTP does not support retransmission. -* @precon nan -* @brief 1. Use the default initialization mode on the client and server. Expected result 1. -* 2. The client initiates a DTLCP connection request. After receiving the client hello packet, the server does not reply with the server hello packet. The delay is 3 seconds. Check the sending buffer of the client. Expected result 2. -* @expect 1: The initialization is successful. -* 2: The sending buffer of the client is empty. -* @prior Level 1 -* @auto TRUE -@ */ -/* BEGIN_CASE */ -void UT_TLS_DTLCP_CONSISTENCY_RFC6083_RETRANSMISSION_TC001(void) -{ - HandshakeTestInfo testInfo = {0}; - testInfo.state = TRY_SEND_CLIENT_HELLO; - testInfo.isSupportExtendMasterSecret = true; - testInfo.isClient = true; - ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); - - CONN_Deinit(testInfo.client->ssl); - - ASSERT_TRUE(testInfo.client->ssl != NULL); - ASSERT_EQ(HITLS_Connect(testInfo.client->ssl), HITLS_REC_NORMAL_RECV_BUF_EMPTY); - - ASSERT_TRUE(FRAME_TrasferMsgBetweenLink(testInfo.client, testInfo.server) == HITLS_SUCCESS); - - sleep(3); - - ASSERT_TRUE(testInfo.client->ssl != NULL); - ASSERT_EQ(HITLS_Connect(testInfo.client->ssl), HITLS_REC_NORMAL_RECV_BUF_EMPTY); - - FrameUioUserData *ioUserData = BSL_UIO_GetUserData(testInfo.client->io); - uint32_t sndLen = ioUserData->sndMsg.len; - ASSERT_TRUE(sndLen == 0); - -EXIT: - HITLS_CFG_FreeConfig(testInfo.config); - FRAME_FreeLink(testInfo.client); - FRAME_FreeLink(testInfo.server); - FRAME_DeRegCryptMethod(); -} -/* END_CASE */ - /* @ * @test UT_TLS_DTLCP_CONSISTENCY_RFC6347_FINISH_TC001 * @spec - @@ -81,7 +35,7 @@ void UT_TLS_DTLCP_CONSISTENCY_RFC6347_FINISH_TC001(void) HandshakeTestInfo testInfo = {0}; testInfo.isClient = false; testInfo.state = TRY_SEND_CHANGE_CIPHER_SPEC; - ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); uint8_t data[MAX_RECORD_LENTH] = {0}; uint32_t len = MAX_RECORD_LENTH; ASSERT_TRUE(GetDisorderServerFinished(testInfo.server, data, len, &len) == HITLS_SUCCESS); @@ -89,8 +43,7 @@ void UT_TLS_DTLCP_CONSISTENCY_RFC6347_FINISH_TC001(void) ASSERT_TRUE(ioUserData->recMsg.len == 0); ASSERT_TRUE(FRAME_TransportRecMsg(testInfo.client->io, data, len) == HITLS_SUCCESS); (void)HITLS_Connect(testInfo.client->ssl); - ASSERT_TRUE(testInfo.client->ssl->state == CM_STATE_HANDSHAKING); - ASSERT_TRUE(testInfo.client->ssl->hsCtx->state == TRY_RECV_FINISH); + ASSERT_EQ(testInfo.client->ssl->state, CM_STATE_TRANSPORTING); EXIT: HITLS_CFG_FreeConfig(testInfo.config); @@ -122,7 +75,7 @@ void UT_TLS_DTLCP_CONSISTENCY_RFC6347_FINISH_TC002(void) HandshakeTestInfo testInfo = {0}; testInfo.isClient = true; testInfo.state = TRY_SEND_CLIENT_KEY_EXCHANGE; - ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); uint8_t data[MAX_RECORD_LENTH] = {0}; uint32_t len = MAX_RECORD_LENTH; ASSERT_TRUE(GetDisorderClientFinished1(testInfo.client, data, len, &len) == HITLS_SUCCESS); @@ -130,8 +83,8 @@ void UT_TLS_DTLCP_CONSISTENCY_RFC6347_FINISH_TC002(void) ASSERT_TRUE(ioUserData->recMsg.len == 0); ASSERT_TRUE(FRAME_TransportRecMsg(testInfo.server->io, data, len) == HITLS_SUCCESS); (void)HITLS_Accept(testInfo.server->ssl); - ASSERT_TRUE(testInfo.server->ssl->state == CM_STATE_HANDSHAKING); - ASSERT_TRUE(testInfo.server->ssl->hsCtx->state == TRY_RECV_FINISH); + ASSERT_EQ(testInfo.server->ssl->state, CM_STATE_HANDSHAKING); + ASSERT_EQ(testInfo.server->ssl->hsCtx->state, TRY_SEND_CHANGE_CIPHER_SPEC); EXIT: FRAME_CleanMsg(&frameType, &frameMsg); @@ -160,7 +113,7 @@ void UT_TLS_DTLCP_CONSISTENCY_RFC6347_FINISH_TC003(void) HandshakeTestInfo testInfo = {0}; testInfo.isClient = false; testInfo.state = TRY_SEND_CHANGE_CIPHER_SPEC; - ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); uint8_t data[MAX_RECORD_LENTH] = {0}; uint32_t len = MAX_RECORD_LENTH; ASSERT_TRUE(GetDisorderServerFinish_AppData(testInfo.server, data, len, &len) == HITLS_SUCCESS); @@ -301,7 +254,7 @@ void UT_TLS_DTLCP_CONSISTENCY_RFC6347_APPDATA_TC001(void) ASSERT_TRUE(ioUserData->recMsg.len == 0); ASSERT_TRUE(FRAME_TransportRecMsg(testInfo.server->io, data, len) == HITLS_SUCCESS); ASSERT_TRUE(HITLS_Read(testInfo.server->ssl, data, MAX_RECORD_LENTH, &len) == HITLS_SUCCESS); - ASSERT_EQ(HITLS_Read(testInfo.server->ssl, data, MAX_RECORD_LENTH, &len), HITLS_SUCCESS); + ASSERT_EQ(HITLS_Read(testInfo.server->ssl, data, MAX_RECORD_LENTH, &len), HITLS_REC_NORMAL_RECV_BUF_EMPTY); uint8_t writeData[] = {"abcd1234"}; uint32_t writeLen = strlen("abcd1234"); uint8_t readData[MAX_RECORD_LENTH] = {0}; @@ -355,7 +308,7 @@ void UT_TLS_DTLCP_CONSISTENCY_RFC6347_APPDATA_TC002(void) ASSERT_TRUE(ioUserData->recMsg.len == 0); ASSERT_TRUE(FRAME_TransportRecMsg(testInfo.client->io, data, len) == HITLS_SUCCESS); ASSERT_TRUE(HITLS_Read(testInfo.client->ssl, data, MAX_RECORD_LENTH, &len) == HITLS_SUCCESS); - ASSERT_EQ(HITLS_Read(testInfo.client->ssl, data, MAX_RECORD_LENTH, &len), HITLS_SUCCESS); + ASSERT_EQ(HITLS_Read(testInfo.client->ssl, data, MAX_RECORD_LENTH, &len), HITLS_REC_NORMAL_RECV_BUF_EMPTY); uint8_t writeData[] = {"abcd1234"}; uint32_t writeLen = strlen("abcd1234"); uint8_t readData[MAX_RECORD_LENTH] = {0}; @@ -406,7 +359,7 @@ void UT_TLS_DTLCP_CONSISTENCY_RFC6347_CLIENT_HELLO_TC001(void) frameType.recordType = REC_TYPE_HANDSHAKE; frameType.handshakeType = CLIENT_HELLO; frameType.keyExType = HITLS_KEY_EXCH_ECDHE; - frameType.transportType = BSL_UIO_SCTP; + frameType.transportType = BSL_UIO_UDP; ASSERT_TRUE(FRAME_GetDefaultMsg(&frameType, &frameMsg) == HITLS_SUCCESS); uint32_t sendLen = MAX_RECORD_LENTH; uint8_t sendBuf[MAX_RECORD_LENTH] = {0}; @@ -460,7 +413,7 @@ void UT_TLS_DTLCP_CONSISTENCY_RFC8422_ECPOINT_TC001(void) testInfo.state = TRY_RECV_SERVER_HELLO; testInfo.isSupportExtendMasterSecret = true; testInfo.isClient = true; - ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); FrameUioUserData *ioUserData = BSL_UIO_GetUserData(testInfo.client->io); uint8_t *recvBuf = ioUserData->recMsg.msg; uint32_t recvLen = ioUserData->recMsg.len; @@ -472,7 +425,7 @@ void UT_TLS_DTLCP_CONSISTENCY_RFC8422_ECPOINT_TC001(void) frameType.recordType = REC_TYPE_HANDSHAKE; frameType.handshakeType = SERVER_HELLO; frameType.keyExType = HITLS_KEY_EXCH_ECDHE; - frameType.transportType = BSL_UIO_SCTP; + frameType.transportType = BSL_UIO_UDP; ASSERT_TRUE(FRAME_ParseMsg(&frameType, recvBuf, recvLen, &frameMsg, &parseLen) == HITLS_SUCCESS); uint8_t Gdata[] = { 0x01 }; FRAME_ServerHelloMsg *serverMsg = &frameMsg.body.hsMsg.body.serverHello; @@ -531,7 +484,7 @@ void UT_TLS_DTLCP_CONSISTENCY_RFC8422_EXTENSION_MISS_TC001(void) testInfo.state = TRY_RECV_CLIENT_HELLO; testInfo.isSupportExtendMasterSecret = true; testInfo.isClient = false; - ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); FrameUioUserData *ioUserData = BSL_UIO_GetUserData(testInfo.server->io); uint8_t *recvBuf = ioUserData->recMsg.msg; uint32_t recvLen = ioUserData->recMsg.len; @@ -543,7 +496,7 @@ void UT_TLS_DTLCP_CONSISTENCY_RFC8422_EXTENSION_MISS_TC001(void) frameType.recordType = REC_TYPE_HANDSHAKE; frameType.handshakeType = CLIENT_HELLO; frameType.keyExType = HITLS_KEY_EXCH_ECDHE; - frameType.transportType = BSL_UIO_SCTP; + frameType.transportType = BSL_UIO_UDP; ASSERT_TRUE(FRAME_ParseMsg(&frameType, recvBuf, recvLen, &frameMsg, &parseLen) == HITLS_SUCCESS); FRAME_ClientHelloMsg *clientMsg = &frameMsg.body.hsMsg.body.clientHello; clientMsg->supportedGroups.exState = MISSING_FIELD; @@ -586,8 +539,8 @@ void UT_DTLCP_RFC6347_RECV_ALERT_AFTER_CCS_TC001() FRAME_Init(); HITLS_Config *tlsConfig = HITLS_CFG_NewDTLCPConfig(); ASSERT_TRUE(tlsConfig != NULL); - FRAME_LinkObj *client = FRAME_CreateTLCPLink(tlsConfig, BSL_UIO_SCTP, true); - FRAME_LinkObj *server = FRAME_CreateTLCPLink(tlsConfig, BSL_UIO_SCTP, false); + FRAME_LinkObj *client = FRAME_CreateTLCPLink(tlsConfig, BSL_UIO_UDP, true); + FRAME_LinkObj *server = FRAME_CreateTLCPLink(tlsConfig, BSL_UIO_UDP, false); client->needStopBeforeRecvCCS = true; server->needStopBeforeRecvCCS = true; ASSERT_TRUE(client != NULL); @@ -642,8 +595,8 @@ void UT_TLS_DTLCP_CONSISTENCY_RFC6347_TC001() HITLS_Config *tlsConfig = HITLS_CFG_NewDTLCPConfig(); tlsConfig->isSupportRenegotiation = true; ASSERT_TRUE(tlsConfig != NULL); - FRAME_LinkObj *client = FRAME_CreateTLCPLink(tlsConfig, BSL_UIO_SCTP, true); - FRAME_LinkObj *server = FRAME_CreateTLCPLink(tlsConfig, BSL_UIO_SCTP, false); + FRAME_LinkObj *client = FRAME_CreateTLCPLink(tlsConfig, BSL_UIO_UDP, true); + FRAME_LinkObj *server = FRAME_CreateTLCPLink(tlsConfig, BSL_UIO_UDP, false); ASSERT_TRUE(client != NULL); ASSERT_TRUE(server != NULL); HITLS_Ctx *clientTlsCtx = FRAME_GetTlsCtx(client); @@ -656,7 +609,7 @@ void UT_TLS_DTLCP_CONSISTENCY_RFC6347_TC001() ASSERT_EQ(FRAME_TrasferMsgBetweenLink(server, client), HITLS_SUCCESS); uint8_t readData[MAX_RECORD_LENTH] = {0}; uint32_t readLen = MAX_RECORD_LENTH; - ASSERT_EQ(HITLS_Read(clientTlsCtx, readData, MAX_RECORD_LENTH, &readLen), HITLS_MSG_HANDLE_UNMATCHED_SEQUENCE); + ASSERT_EQ(HITLS_Read(clientTlsCtx, readData, MAX_RECORD_LENTH, &readLen), HITLS_REC_NORMAL_RECV_BUF_EMPTY); EXIT: HITLS_CFG_FreeConfig(tlsConfig); FRAME_FreeLink(client); diff --git a/testcode/sdv/testcase/tls/consistency/dtlcp/test_suite_sdv_frame_dtlcp_consistency.data b/testcode/sdv/testcase/tls/consistency/dtlcp/test_suite_sdv_frame_dtlcp_consistency.data index 59f0d9ab..7ef50ffc 100644 --- a/testcode/sdv/testcase/tls/consistency/dtlcp/test_suite_sdv_frame_dtlcp_consistency.data +++ b/testcode/sdv/testcase/tls/consistency/dtlcp/test_suite_sdv_frame_dtlcp_consistency.data @@ -1,6 +1,3 @@ -UT_TLS_DTLCP_CONSISTENCY_RFC6083_RETRANSMISSION_TC001 -UT_TLS_DTLCP_CONSISTENCY_RFC6083_RETRANSMISSION_TC001: - UT_TLS_DTLCP_CONSISTENCY_RFC6347_FINISH_TC001 UT_TLS_DTLCP_CONSISTENCY_RFC6347_FINISH_TC001: @@ -13,6 +10,9 @@ UT_TLS_DTLCP_CONSISTENCY_RFC6347_FINISH_TC003: UT_TLS_DTLCP_CONSISTENCY_RFC6347_DISORDER_TC001 UT_TLS_DTLCP_CONSISTENCY_RFC6347_DISORDER_TC001: +UT_TLS_DTLCP_CONSISTENCY_RFC6347_DISORDER_TC002 +UT_TLS_DTLCP_CONSISTENCY_RFC6347_DISORDER_TC002: + UT_TLS_DTLCP_CONSISTENCY_RFC6347_APPDATA_TC001 UT_TLS_DTLCP_CONSISTENCY_RFC6347_APPDATA_TC001: diff --git a/testcode/sdv/testcase/tls/consistency/dtlcp/test_suite_sdv_hlt_dtlcp_consistency.c b/testcode/sdv/testcase/tls/consistency/dtlcp/test_suite_sdv_hlt_dtlcp_consistency.c index 8739152c..9a196525 100644 --- a/testcode/sdv/testcase/tls/consistency/dtlcp/test_suite_sdv_hlt_dtlcp_consistency.c +++ b/testcode/sdv/testcase/tls/consistency/dtlcp/test_suite_sdv_hlt_dtlcp_consistency.c @@ -221,84 +221,4 @@ EXIT: HITLS_SESS_Free(session); HLT_FreeAllProcess(); } -/* END_CASE */ -static int32_t DtlsSctpUioWriteException(BSL_UIO *uio, const void *buf, uint32_t len, uint32_t *writeLen) -{ - int32_t ret; - static int32_t count = 0; - count++; - if (count == 1) { - ret = SctpDefaultWrite(uio, (uint8_t *)buf, len / 2, writeLen); - } else { - ret = SctpDefaultWrite(uio, (uint8_t *)buf, len, writeLen); - } - return ret; -} -/** -* @test SDV_TLS_DTLCP_WRITE_APP_FAILED_TC001 -* @spec - -* @title The client and server receive the client Hello message after the connection establishment is complete. -* @precon nan -* @brief -* 1. Use the default configuration items to configure the client and server. Expected result 1. -* 2. A DTLCP over SCTP connection is established between the client and server. Expected result 2. -* 3. Construct a app message and send it to the client. Check the server ret. Expected result 3. -* 4. Construct a app message and send it to the client. Check the server ret. Expected result 4. -* @expect -* 1. The initialization is successful. -* 2. The connection is set up successfully. -* 3. The server ret is HITLS_REC_ERR_IO_EXCEPTION. -* 4. The server ret is HITLS_SUCCESS. -* @prior Level 1 -* @auto TRUE -@ */ -/* BEGIN_CASE */ -void SDV_TLS_DTLCP_WRITE_APP_FAILED_TC001(int version, int connType) -{ - if (connType == SCTP && !IsEnableSctpAuth()){ - return; - } - bool certverifyflag = true; - - HLT_Tls_Res *serverRes = NULL; - HLT_Tls_Res *clientRes = NULL; - HLT_Process *localProcess = NULL; - HLT_Process *remoteProcess = NULL; - - localProcess = HLT_InitLocalProcess(HITLS); - ASSERT_TRUE(localProcess != NULL); - remoteProcess = HLT_LinkRemoteProcess(HITLS, connType, 16790, true); - ASSERT_TRUE(remoteProcess != NULL); - - HLT_Ctx_Config *serverCtxConfig = HLT_NewCtxConfigTLCP(NULL, "SERVER", false); - ASSERT_TRUE(serverCtxConfig != NULL); - - serverCtxConfig->isSupportClientVerify = certverifyflag; - - serverRes = HLT_ProcessTlsAccept(localProcess, version, serverCtxConfig, NULL); - ASSERT_TRUE(serverRes != NULL); - - HLT_Ctx_Config *clientCtxConfig = HLT_NewCtxConfigTLCP(NULL, "CLIENT", true); - ASSERT_TRUE(clientCtxConfig != NULL); - - clientCtxConfig->isSupportClientVerify = certverifyflag; - - clientRes = HLT_ProcessTlsConnect(remoteProcess, version, clientCtxConfig, NULL); - ASSERT_TRUE(clientRes != NULL); - - ASSERT_TRUE(HLT_GetTlsAcceptResult(serverRes) == 0); - - HITLS_Ctx *ctx = serverRes->ssl; - BSL_UIO *uio = ctx->uio; - uio->method.write = DtlsSctpUioWriteException; - ASSERT_EQ(HLT_ProcessTlsWrite(localProcess, serverRes, (uint8_t *)"Hello World", strlen("Hello World")), HITLS_REC_ERR_IO_EXCEPTION); - ASSERT_EQ(HLT_ProcessTlsWrite(localProcess, serverRes, (uint8_t *)"Hello World2", strlen("Hello World2")), HITLS_SUCCESS); - uint8_t readBuf[1024] = {0}; - uint32_t readLen; - ASSERT_TRUE(HLT_ProcessTlsRead(remoteProcess, clientRes, readBuf, sizeof(readBuf), &readLen) == 0); - ASSERT_TRUE(readLen == strlen("Hello World2")); - ASSERT_TRUE(memcmp("Hello World2", readBuf, readLen) == 0); -EXIT: - HLT_FreeAllProcess(); -} /* END_CASE */ \ No newline at end of file diff --git a/testcode/sdv/testcase/tls/consistency/dtlcp/test_suite_sdv_hlt_dtlcp_consistency.data b/testcode/sdv/testcase/tls/consistency/dtlcp/test_suite_sdv_hlt_dtlcp_consistency.data index a4b9c045..990a5168 100644 --- a/testcode/sdv/testcase/tls/consistency/dtlcp/test_suite_sdv_hlt_dtlcp_consistency.data +++ b/testcode/sdv/testcase/tls/consistency/dtlcp/test_suite_sdv_hlt_dtlcp_consistency.data @@ -4,5 +4,3 @@ SDV_TLS_DTLCP_HANDSHAKE_FUNC_TC001:SCTP SDV_TLS_DTLCP_CONSISTENCY_RFC5246_UNEXPETED_REORD_TYPE_TC001 tls12 SDV_TLS_DTLCP_CONSISTENCY_RFC5246_UNEXPETED_REORD_TYPE_TC001: -SDV_TLS_DTLCP_WRITE_APP_FAILED_TC001 -SDV_TLS_DTLCP_WRITE_APP_FAILED_TC001:DTLCP1_1:SCTP diff --git a/testcode/sdv/testcase/tls/consistency/dtls12/test_suite_sdv_frame_dtls12_consistency.c b/testcode/sdv/testcase/tls/consistency/dtls12/test_suite_sdv_frame_dtls12_consistency.c index a6d40daf..a59d39cd 100644 --- a/testcode/sdv/testcase/tls/consistency/dtls12/test_suite_sdv_frame_dtls12_consistency.c +++ b/testcode/sdv/testcase/tls/consistency/dtls12/test_suite_sdv_frame_dtls12_consistency.c @@ -45,12 +45,12 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_UNEXPETED_REORD_TYPE_TC001(void) testInfo.state = HS_STATE_BUTT; testInfo.isClient = false; testInfo.isSupportExtendMasterSecret = true; - ASSERT_TRUE(DefaultCfgStatusParkWithSuite(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusParkWithSuite(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); frameType.versionType = HITLS_VERSION_DTLS12; frameType.recordType = REC_TYPE_HANDSHAKE; frameType.handshakeType = CLIENT_HELLO; frameType.keyExType = HITLS_KEY_EXCH_ECDHE; - frameType.transportType = BSL_UIO_SCTP; + frameType.transportType = BSL_UIO_UDP; ASSERT_TRUE(FRAME_GetDefaultMsg(&frameType, &frameMsg) == HITLS_SUCCESS); uint32_t sendLen = MAX_RECORD_LENTH; uint8_t sendBuf[MAX_RECORD_LENTH] = {0}; @@ -449,7 +449,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_ZERO_TC001(void) testInfo.state = TRY_RECV_CLIENT_HELLO; testInfo.isSupportExtendMasterSecret = true; testInfo.isClient = false; - ASSERT_TRUE(DefaultCfgStatusParkWithSuite(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusParkWithSuite(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); FrameUioUserData *ioUserData = BSL_UIO_GetUserData(testInfo.server->io); uint8_t *recvBuf = ioUserData->recMsg.msg; uint32_t recvLen = ioUserData->recMsg.len; @@ -459,7 +459,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_ZERO_TC001(void) frameType.recordType = REC_TYPE_HANDSHAKE; frameType.handshakeType = CLIENT_HELLO; frameType.keyExType = HITLS_KEY_EXCH_ECDHE; - frameType.transportType = BSL_UIO_SCTP; + frameType.transportType = BSL_UIO_UDP; ASSERT_TRUE(FRAME_ParseMsg(&frameType, recvBuf, recvLen, &frameMsg, &parseLen) == HITLS_SUCCESS); FRAME_ClientHelloMsg *clientMsg = &frameMsg.body.hsMsg.body.clientHello; clientMsg->extensionState = MISSING_FIELD; @@ -526,7 +526,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_ZERO_TC002(void) testInfo.state = TRY_RECV_SERVER_HELLO; testInfo.isSupportExtendMasterSecret = true; testInfo.isClient = true; - ASSERT_TRUE(DefaultCfgStatusParkWithSuite(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusParkWithSuite(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); FrameUioUserData *ioUserData = BSL_UIO_GetUserData(testInfo.client->io); uint8_t *recvBuf = ioUserData->recMsg.msg; uint32_t recvLen = ioUserData->recMsg.len; @@ -536,7 +536,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_ZERO_TC002(void) frameType.recordType = REC_TYPE_HANDSHAKE; frameType.handshakeType = SERVER_HELLO; frameType.keyExType = HITLS_KEY_EXCH_ECDHE; - frameType.transportType = BSL_UIO_SCTP; + frameType.transportType = BSL_UIO_UDP; ASSERT_TRUE(FRAME_ParseMsg(&frameType, recvBuf, recvLen, &frameMsg, &parseLen) == HITLS_SUCCESS); FRAME_ServerHelloMsg *serverMsg = &frameMsg.body.hsMsg.body.serverHello; serverMsg->version.state = MISSING_FIELD; @@ -601,7 +601,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_ZERO_TC003(void) testInfo.state = TRY_RECV_CERTIFICATE; testInfo.isSupportExtendMasterSecret = true; testInfo.isClient = true; - ASSERT_TRUE(DefaultCfgStatusParkWithSuite(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusParkWithSuite(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); FrameUioUserData *ioUserData = BSL_UIO_GetUserData(testInfo.client->io); uint8_t *recvBuf = ioUserData->recMsg.msg; uint32_t recvLen = ioUserData->recMsg.len; @@ -611,7 +611,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_ZERO_TC003(void) frameType.recordType = REC_TYPE_HANDSHAKE; frameType.handshakeType = CERTIFICATE; frameType.keyExType = HITLS_KEY_EXCH_ECDHE; - frameType.transportType = BSL_UIO_SCTP; + frameType.transportType = BSL_UIO_UDP; ASSERT_TRUE(FRAME_ParseMsg(&frameType, recvBuf, recvLen, &frameMsg, &parseLen) == HITLS_SUCCESS); FRAME_CertificateMsg *certifiMsg = &frameMsg.body.hsMsg.body.certificate; certifiMsg->certsLen.state = MISSING_FIELD; @@ -668,7 +668,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_ZERO_TC004(void) testInfo.state = TRY_RECV_SERVER_KEY_EXCHANGE; testInfo.isSupportExtendMasterSecret = true; testInfo.isClient = true; - ASSERT_TRUE(DefaultCfgStatusParkWithSuite(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusParkWithSuite(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); FrameUioUserData *ioUserData = BSL_UIO_GetUserData(testInfo.client->io); uint8_t *recvBuf = ioUserData->recMsg.msg; uint32_t recvLen = ioUserData->recMsg.len; @@ -678,7 +678,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_ZERO_TC004(void) frameType.recordType = REC_TYPE_HANDSHAKE; frameType.handshakeType = SERVER_KEY_EXCHANGE; frameType.keyExType = HITLS_KEY_EXCH_ECDHE; - frameType.transportType = BSL_UIO_SCTP; + frameType.transportType = BSL_UIO_UDP; ASSERT_TRUE(FRAME_ParseMsg(&frameType, recvBuf, recvLen, &frameMsg, &parseLen) == HITLS_SUCCESS); FRAME_ServerKeyExchangeMsg *serverKeyExMsg = &frameMsg.body.hsMsg.body.serverKeyExchange; serverKeyExMsg->keyEx.ecdh.curveType.state = MISSING_FIELD; @@ -740,7 +740,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_ZERO_TC005(void) testInfo.state = TRY_RECV_CLIENT_KEY_EXCHANGE; testInfo.isSupportExtendMasterSecret = true; testInfo.isClient = false; - ASSERT_TRUE(DefaultCfgStatusParkWithSuite(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusParkWithSuite(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); FrameUioUserData *ioUserData = BSL_UIO_GetUserData(testInfo.server->io); uint8_t *recvBuf = ioUserData->recMsg.msg; uint32_t recvLen = ioUserData->recMsg.len; @@ -750,7 +750,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_ZERO_TC005(void) frameType.recordType = REC_TYPE_HANDSHAKE; frameType.handshakeType = CLIENT_KEY_EXCHANGE; frameType.keyExType = HITLS_KEY_EXCH_ECDHE; - frameType.transportType = BSL_UIO_SCTP; + frameType.transportType = BSL_UIO_UDP; ASSERT_TRUE(FRAME_ParseMsg(&frameType, recvBuf, recvLen, &frameMsg, &parseLen) == HITLS_SUCCESS); FRAME_ClientKeyExchangeMsg *clientKeyExMsg = &frameMsg.body.hsMsg.body.clientKeyExchange; clientKeyExMsg->pubKey.state = MISSING_FIELD; @@ -805,14 +805,14 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_ZERO_TC006(void) testInfo.state = TRY_RECV_CLIENT_KEY_EXCHANGE; testInfo.isSupportExtendMasterSecret = true; testInfo.isClient = false; - ASSERT_TRUE(DefaultCfgStatusParkWithSuite(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusParkWithSuite(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); ASSERT_TRUE(testInfo.server->ssl != NULL); ASSERT_EQ(HITLS_Accept(testInfo.server->ssl), HITLS_REC_NORMAL_RECV_BUF_EMPTY); FRAME_Msg frameMsg1 = {0}; FRAME_Type frameType1 = {0}; frameType1.versionType = HITLS_VERSION_DTLS12; frameType1.recordType = REC_TYPE_CHANGE_CIPHER_SPEC; - frameType1.transportType = BSL_UIO_SCTP; + frameType1.transportType = BSL_UIO_UDP; ASSERT_TRUE(FRAME_GetDefaultMsg(&frameType1, &frameMsg1) == HITLS_SUCCESS); FRAME_CcsMsg *CcsMidMsg = &frameMsg1.body.ccsMsg; CcsMidMsg->ccsType.state = MISSING_FIELD; @@ -855,14 +855,14 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_ZERO_TC007(void) testInfo.state = TRY_SEND_FINISH; testInfo.isSupportExtendMasterSecret = true; testInfo.isClient = true; - ASSERT_TRUE(DefaultCfgStatusParkWithSuite(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusParkWithSuite(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); ASSERT_TRUE(testInfo.server->ssl != NULL); ASSERT_EQ(HITLS_Connect(testInfo.server->ssl), HITLS_REC_NORMAL_RECV_BUF_EMPTY); FRAME_Msg frameMsg1 = {0}; FRAME_Type frameType1 = {0}; frameType1.versionType = HITLS_VERSION_DTLS12; frameType1.recordType = REC_TYPE_CHANGE_CIPHER_SPEC; - frameType1.transportType = BSL_UIO_SCTP; + frameType1.transportType = BSL_UIO_UDP; ASSERT_TRUE(FRAME_GetDefaultMsg(&frameType1, &frameMsg1) == HITLS_SUCCESS); FRAME_CcsMsg *CcsMidMsg = &frameMsg1.body.ccsMsg; CcsMidMsg->ccsType.state = MISSING_FIELD; @@ -1040,7 +1040,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_CIPHER_TC001(void) testInfo.state = TRY_RECV_CLIENT_HELLO; testInfo.isSupportExtendMasterSecret = true; testInfo.isClient = false; - ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); FrameUioUserData *ioUserData = BSL_UIO_GetUserData(testInfo.server->io); uint8_t *recvBuf = ioUserData->recMsg.msg; uint32_t recvLen = ioUserData->recMsg.len; @@ -1050,7 +1050,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_CIPHER_TC001(void) frameType.recordType = REC_TYPE_HANDSHAKE; frameType.handshakeType = CLIENT_HELLO; frameType.keyExType = HITLS_KEY_EXCH_ECDHE; - frameType.transportType = BSL_UIO_SCTP; + frameType.transportType = BSL_UIO_UDP; ASSERT_TRUE(FRAME_ParseMsg(&frameType, recvBuf, recvLen, &frameMsg, &parseLen) == HITLS_SUCCESS); uint16_t suite[] = {0x00B6, 0x00B7, ILLEGAL_VALUE, HITLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}; FRAME_ClientHelloMsg *clientMsg = &frameMsg.body.hsMsg.body.clientHello; @@ -1106,7 +1106,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_CIPHER_TC002(void) testInfo.state = TRY_RECV_SERVER_HELLO; testInfo.isSupportExtendMasterSecret = true; testInfo.isClient = true; - ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); FrameUioUserData *ioUserData = BSL_UIO_GetUserData(testInfo.client->io); uint8_t *recvBuf = ioUserData->recMsg.msg; uint32_t recvLen = ioUserData->recMsg.len; @@ -1116,7 +1116,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_CIPHER_TC002(void) frameType.recordType = REC_TYPE_HANDSHAKE; frameType.handshakeType = SERVER_HELLO; frameType.keyExType = HITLS_KEY_EXCH_ECDHE; - frameType.transportType = BSL_UIO_SCTP; + frameType.transportType = BSL_UIO_UDP; ASSERT_TRUE(FRAME_ParseMsg(&frameType, recvBuf, recvLen, &frameMsg, &parseLen) == HITLS_SUCCESS); FRAME_ServerHelloMsg *serverMsg = &frameMsg.body.hsMsg.body.serverHello; serverMsg->cipherSuite.data = ILLEGAL_VALUE; @@ -1174,7 +1174,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC001(void) testInfo.isClient = false; testInfo.isSupportExtendMasterSecret = true; testInfo.isSupportClientVerify = true; - ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); FrameUioUserData *ioUserData = BSL_UIO_GetUserData(testInfo.server->io); uint8_t *recvBuf = ioUserData->recMsg.msg; uint32_t recvLen = ioUserData->recMsg.len; @@ -1184,7 +1184,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC001(void) frameType.recordType = REC_TYPE_HANDSHAKE; frameType.handshakeType = CLIENT_HELLO; frameType.keyExType = HITLS_KEY_EXCH_ECDHE; - frameType.transportType = BSL_UIO_SCTP; + frameType.transportType = BSL_UIO_UDP; ASSERT_TRUE(FRAME_ParseMsg(&frameType, recvBuf, recvLen, &frameMsg, &parseLen) == HITLS_SUCCESS); ASSERT_TRUE(frameMsg.body.hsMsg.type.data == CLIENT_HELLO); frameMsg.body.hsMsg.body.clientHello.signatureAlgorithms.exState = MISSING_FIELD; @@ -1238,7 +1238,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC002(void) testInfo.state = TRY_RECV_SERVER_HELLO; testInfo.isSupportExtendMasterSecret = true; testInfo.isClient = true; - ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); FrameUioUserData *ioUserData = BSL_UIO_GetUserData(testInfo.client->io); uint8_t *recvBuf = ioUserData->recMsg.msg; uint32_t recvLen = ioUserData->recMsg.len; @@ -1248,7 +1248,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC002(void) frameType.recordType = REC_TYPE_HANDSHAKE; frameType.handshakeType = SERVER_HELLO; frameType.keyExType = HITLS_KEY_EXCH_ECDHE; - frameType.transportType = BSL_UIO_SCTP; + frameType.transportType = BSL_UIO_UDP; ASSERT_TRUE(FRAME_ParseMsg(&frameType, recvBuf, recvLen, &frameMsg, &parseLen) == HITLS_SUCCESS); FRAME_ServerHelloMsg *serverMsg = &frameMsg.body.hsMsg.body.serverHello; serverMsg->secRenego.exState = INITIAL_FIELD; @@ -1376,7 +1376,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC004(void) testInfo.state = TRY_RECV_CLIENT_HELLO; testInfo.isSupportExtendMasterSecret = true; testInfo.isClient = false; - ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); FrameUioUserData *ioUserData = BSL_UIO_GetUserData(testInfo.server->io); uint8_t *recvBuf = ioUserData->recMsg.msg; uint32_t recvLen = ioUserData->recMsg.len; @@ -1386,7 +1386,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC004(void) frameType.recordType = REC_TYPE_HANDSHAKE; frameType.handshakeType = CLIENT_HELLO; frameType.keyExType = HITLS_KEY_EXCH_ECDHE; - frameType.transportType = BSL_UIO_SCTP; + frameType.transportType = BSL_UIO_UDP; ASSERT_TRUE(FRAME_ParseMsg(&frameType, recvBuf, recvLen, &frameMsg, &parseLen) == HITLS_SUCCESS); FRAME_ClientHelloMsg *clientMsg = &frameMsg.body.hsMsg.body.clientHello; uint16_t Signature[] = {ILLEGAL_VALUE}; @@ -1445,7 +1445,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC005(void) testInfo.state = TRY_RECV_SERVER_HELLO; testInfo.isSupportExtendMasterSecret = true; testInfo.isClient = true; - ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); FrameUioUserData *ioUserData = BSL_UIO_GetUserData(testInfo.client->io); uint8_t *recvBuf = ioUserData->recMsg.msg; uint32_t recvLen = ioUserData->recMsg.len; @@ -1455,7 +1455,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC005(void) frameType.recordType = REC_TYPE_HANDSHAKE; frameType.handshakeType = SERVER_HELLO; frameType.keyExType = HITLS_KEY_EXCH_ECDHE; - frameType.transportType = BSL_UIO_SCTP; + frameType.transportType = BSL_UIO_UDP; ASSERT_TRUE(FRAME_ParseMsg(&frameType, recvBuf, recvLen, &frameMsg, &parseLen) == HITLS_SUCCESS); FRAME_ServerHelloMsg *serverMsg = &frameMsg.body.hsMsg.body.serverHello; serverMsg->secRenego.exState = INITIAL_FIELD; @@ -1617,65 +1617,6 @@ EXIT: } /* END_CASE */ -/* @ -* @test UT_TLS_DTLS_CONSISTENCY_RFC5246_CERTIFICATE_TC004 -* @spec - -* @title In dual-end verification, the server receives out-of-order Certificate Verify messages. -* @precon nan -* @brief 1. Retain the default configuration on the client and server, and enable peer verification on the server. Expected result 1. -* 2. After sending the server hello done message, the client constructs a Certificate Verify message and sends it to the server. -* @expect 1. The initialization is successful. -* 2. The client sends the ALERT message. The ALERT level is ALERT_LEVEL_FATAL and the description is ALERT_UNEXPECTED_MESSAGE. -* @prior Level 1 -* @auto TRUE -@ */ -/* BEGIN_CASE */ -void UT_TLS_DTLS_CONSISTENCY_RFC5246_CERTIFICATE_TC004(void) -{ - HandshakeTestInfo testInfo = {0}; - FRAME_Msg frameMsg = {0}; - FRAME_Type frameType = {0}; - testInfo.state = TRY_RECV_CERTIFICATE; - testInfo.isClient = false; - testInfo.isSupportExtendMasterSecret = true; - testInfo.isSupportClientVerify = true; - ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); - frameType.versionType = HITLS_VERSION_DTLS12; - frameType.recordType = REC_TYPE_HANDSHAKE; - frameType.handshakeType = CERTIFICATE_VERIFY; - frameType.keyExType = HITLS_KEY_EXCH_ECDHE; - frameType.transportType = BSL_UIO_SCTP; - ASSERT_TRUE(FRAME_GetDefaultMsg(&frameType, &frameMsg) == HITLS_SUCCESS); - uint32_t sendLen = MAX_RECORD_LENTH; - uint8_t sendBuf[MAX_RECORD_LENTH] = {0}; - ASSERT_TRUE(FRAME_PackMsg(&frameType, &frameMsg, sendBuf, sendLen, &sendLen) == HITLS_SUCCESS); - FrameUioUserData *ioUserData = BSL_UIO_GetUserData(testInfo.server->io); - ioUserData->recMsg.len = 0; - ASSERT_TRUE(FRAME_TransportRecMsg(testInfo.server->io, sendBuf, sendLen) == HITLS_SUCCESS); - FRAME_CleanMsg(&frameType, &frameMsg); - memset_s(&frameMsg, sizeof(frameMsg), 0, sizeof(frameMsg)); - ASSERT_TRUE(testInfo.server->ssl != NULL); - ASSERT_EQ(HITLS_Accept(testInfo.server->ssl), HITLS_MSG_HANDLE_UNMATCHED_SEQUENCE); - ioUserData = BSL_UIO_GetUserData(testInfo.server->io); - uint8_t *sndBuf = ioUserData->sndMsg.msg; - uint32_t sndLen = ioUserData->sndMsg.len; - ASSERT_TRUE(sndLen != 0); - uint32_t parseLen = 0; - frameType.recordType = REC_TYPE_ALERT; - ASSERT_TRUE(FRAME_ParseMsg(&frameType, sndBuf, sndLen, &frameMsg, &parseLen) == HITLS_SUCCESS); - ASSERT_TRUE(frameMsg.recType.data == REC_TYPE_ALERT); - FRAME_AlertMsg *alertMsg = &frameMsg.body.alertMsg; - ASSERT_TRUE(alertMsg->alertLevel.data == ALERT_LEVEL_FATAL); - ASSERT_TRUE(alertMsg->alertDescription.data == ALERT_UNEXPECTED_MESSAGE); -EXIT: - FRAME_CleanMsg(&frameType, &frameMsg); - HITLS_CFG_FreeConfig(testInfo.config); - FRAME_FreeLink(testInfo.client); - FRAME_FreeLink(testInfo.server); - FRAME_DeRegCryptMethod(); -} -/* END_CASE */ - /* @ * @test UT_TLS_DTLS_CONSISTENCY_RFC5246_VERSION_TC001 * @spec - @@ -2083,51 +2024,6 @@ EXIT: } /* END_CASE */ -/* @ -* @test UT_TLS_DTLS_CONSISTENCY_RFC6083_RETRANSMISSION_TC001 -* @spec - -* @title Check that DTLS over SCTP does not support retransmission. -* @precon nan -* @brief 1. Use the default initialization mode on the client and server. Expected result 1. -* 2. The client initiates a DTLS connection request. After receiving the client hello packet, the server does not reply with the server hello packet. The delay is 3 seconds. Check the sending buffer of the client. Expected result 2. -* @expect 1: The initialization is successful. -* 2: The sending buffer of the client is empty. -* @prior Level 1 -* @auto TRUE -@ */ -/* BEGIN_CASE */ -void UT_TLS_DTLS_CONSISTENCY_RFC6083_RETRANSMISSION_TC001(void) -{ - HandshakeTestInfo testInfo = {0}; - testInfo.state = TRY_SEND_CLIENT_HELLO; - testInfo.isSupportExtendMasterSecret = true; - testInfo.isClient = true; - ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); - - CONN_Deinit(testInfo.client->ssl); - - ASSERT_TRUE(testInfo.client->ssl != NULL); - ASSERT_EQ(HITLS_Connect(testInfo.client->ssl), HITLS_REC_NORMAL_RECV_BUF_EMPTY); - - ASSERT_TRUE(FRAME_TrasferMsgBetweenLink(testInfo.client, testInfo.server) == HITLS_SUCCESS); - - sleep(3); - - ASSERT_TRUE(testInfo.client->ssl != NULL); - ASSERT_EQ(HITLS_Connect(testInfo.client->ssl), HITLS_REC_NORMAL_RECV_BUF_EMPTY); - - FrameUioUserData *ioUserData = BSL_UIO_GetUserData(testInfo.client->io); - uint32_t sndLen = ioUserData->sndMsg.len; - ASSERT_TRUE(sndLen == 0); - -EXIT: - HITLS_CFG_FreeConfig(testInfo.config); - FRAME_FreeLink(testInfo.client); - FRAME_FreeLink(testInfo.server); - FRAME_DeRegCryptMethod(); -} -/* END_CASE */ - /* @ * @test UT_TLS_DTLS_CONSISTENCY_RFC6347_FINISH_TC001 * @spec - @@ -2146,7 +2042,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC6347_FINISH_TC001(void) HandshakeTestInfo testInfo = {0}; testInfo.isClient = false; testInfo.state = TRY_SEND_CHANGE_CIPHER_SPEC; - ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); uint8_t data[MAX_RECORD_LENTH] = {0}; uint32_t len = MAX_RECORD_LENTH; ASSERT_TRUE(GetDisorderServerFinished(testInfo.server, data, len, &len) == HITLS_SUCCESS); @@ -2154,8 +2050,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC6347_FINISH_TC001(void) ASSERT_TRUE(ioUserData->recMsg.len == 0); ASSERT_TRUE(FRAME_TransportRecMsg(testInfo.client->io, data, len) == HITLS_SUCCESS); (void)HITLS_Connect(testInfo.client->ssl); - ASSERT_TRUE(testInfo.client->ssl->state == CM_STATE_HANDSHAKING); - ASSERT_TRUE(testInfo.client->ssl->hsCtx->state == TRY_RECV_FINISH); + ASSERT_EQ(testInfo.client->ssl->state, CM_STATE_TRANSPORTING); EXIT: HITLS_CFG_FreeConfig(testInfo.config); @@ -2185,7 +2080,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC6347_FINISH_TC002(void) HandshakeTestInfo testInfo = {0}; testInfo.isClient = true; testInfo.state = TRY_SEND_CLIENT_KEY_EXCHANGE; - ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); uint8_t data[MAX_RECORD_LENTH] = {0}; uint32_t len = MAX_RECORD_LENTH; ASSERT_TRUE(GetDisorderClientFinished(testInfo.client, data, len, &len) == HITLS_SUCCESS); @@ -2193,8 +2088,8 @@ void UT_TLS_DTLS_CONSISTENCY_RFC6347_FINISH_TC002(void) ASSERT_TRUE(ioUserData->recMsg.len == 0); ASSERT_TRUE(FRAME_TransportRecMsg(testInfo.server->io, data, len) == HITLS_SUCCESS); (void)HITLS_Accept(testInfo.server->ssl); - ASSERT_TRUE(testInfo.server->ssl->state == CM_STATE_HANDSHAKING); - ASSERT_TRUE(testInfo.server->ssl->hsCtx->state == TRY_RECV_FINISH); + ASSERT_EQ(testInfo.server->ssl->state, CM_STATE_HANDSHAKING); + ASSERT_EQ(testInfo.server->ssl->hsCtx->state, TRY_SEND_CHANGE_CIPHER_SPEC); EXIT: FRAME_CleanMsg(&frameType, &frameMsg); @@ -2486,11 +2381,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC6347_APPDATA_TC002(int uioType) ASSERT_TRUE(ioUserData->recMsg.len == 0); ASSERT_TRUE(FRAME_TransportRecMsg(testInfo.client->io, data, len) == HITLS_SUCCESS); ASSERT_TRUE(HITLS_Read(testInfo.client->ssl, data, MAX_RECORD_LENTH, &len) == HITLS_SUCCESS); - if (uioType == BSL_UIO_SCTP) { - ASSERT_EQ(HITLS_Read(testInfo.client->ssl, data, MAX_RECORD_LENTH, &len), HITLS_SUCCESS); - } else { - ASSERT_EQ(HITLS_Read(testInfo.client->ssl, data, MAX_RECORD_LENTH, &len), HITLS_REC_NORMAL_RECV_BUF_EMPTY); - } + ASSERT_EQ(HITLS_Read(testInfo.client->ssl, data, MAX_RECORD_LENTH, &len), HITLS_REC_NORMAL_RECV_BUF_EMPTY); uint8_t writeData[] = {"abcd1234"}; uint32_t writeLen = strlen("abcd1234"); uint8_t readData[MAX_RECORD_LENTH] = {0}; @@ -2541,7 +2432,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC6347_CLIENT_HELLO_TC001(int uioType) frameType.recordType = REC_TYPE_HANDSHAKE; frameType.handshakeType = CLIENT_HELLO; frameType.keyExType = HITLS_KEY_EXCH_ECDHE; - frameType.transportType = BSL_UIO_SCTP; + frameType.transportType = BSL_UIO_UDP; ASSERT_TRUE(FRAME_GetDefaultMsg(&frameType, &frameMsg) == HITLS_SUCCESS); uint32_t sendLen = MAX_RECORD_LENTH; uint8_t sendBuf[MAX_RECORD_LENTH] = {0}; @@ -2809,7 +2700,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC8422_ECPOINT_TC001(void) testInfo.state = TRY_RECV_SERVER_HELLO; testInfo.isSupportExtendMasterSecret = true; testInfo.isClient = true; - ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); FrameUioUserData *ioUserData = BSL_UIO_GetUserData(testInfo.client->io); uint8_t *recvBuf = ioUserData->recMsg.msg; uint32_t recvLen = ioUserData->recMsg.len; @@ -2821,7 +2712,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC8422_ECPOINT_TC001(void) frameType.recordType = REC_TYPE_HANDSHAKE; frameType.handshakeType = SERVER_HELLO; frameType.keyExType = HITLS_KEY_EXCH_ECDHE; - frameType.transportType = BSL_UIO_SCTP; + frameType.transportType = BSL_UIO_UDP; ASSERT_TRUE(FRAME_ParseMsg(&frameType, recvBuf, recvLen, &frameMsg, &parseLen) == HITLS_SUCCESS); uint8_t Gdata[] = { 0x01 }; FRAME_ServerHelloMsg *serverMsg = &frameMsg.body.hsMsg.body.serverHello; @@ -2880,7 +2771,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC8422_EXTENSION_MISS_TC001(void) testInfo.state = TRY_RECV_CLIENT_HELLO; testInfo.isSupportExtendMasterSecret = true; testInfo.isClient = false; - ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_SCTP) == HITLS_SUCCESS); + ASSERT_TRUE(DefaultCfgStatusPark(&testInfo, BSL_UIO_UDP) == HITLS_SUCCESS); FrameUioUserData *ioUserData = BSL_UIO_GetUserData(testInfo.server->io); uint8_t *recvBuf = ioUserData->recMsg.msg; uint32_t recvLen = ioUserData->recMsg.len; @@ -2892,7 +2783,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC8422_EXTENSION_MISS_TC001(void) frameType.recordType = REC_TYPE_HANDSHAKE; frameType.handshakeType = CLIENT_HELLO; frameType.keyExType = HITLS_KEY_EXCH_ECDHE; - frameType.transportType = BSL_UIO_SCTP; + frameType.transportType = BSL_UIO_UDP; ASSERT_TRUE(FRAME_ParseMsg(&frameType, recvBuf, recvLen, &frameMsg, &parseLen) == HITLS_SUCCESS); FRAME_ClientHelloMsg *clientMsg = &frameMsg.body.hsMsg.body.clientHello; clientMsg->supportedGroups.exState = MISSING_FIELD; @@ -2991,8 +2882,8 @@ void UT_TLS_DTLS_CONSISTENCY_RFC6347_TC001() HITLS_Config *tlsConfig = HITLS_CFG_NewDTLS12Config(); tlsConfig->isSupportRenegotiation = true; ASSERT_TRUE(tlsConfig != NULL); - FRAME_LinkObj *client = FRAME_CreateLink(tlsConfig, BSL_UIO_SCTP); - FRAME_LinkObj *server = FRAME_CreateLink(tlsConfig, BSL_UIO_SCTP); + FRAME_LinkObj *client = FRAME_CreateLink(tlsConfig, BSL_UIO_UDP); + FRAME_LinkObj *server = FRAME_CreateLink(tlsConfig, BSL_UIO_UDP); ASSERT_TRUE(client != NULL); ASSERT_TRUE(server != NULL); HITLS_Ctx *clientTlsCtx = FRAME_GetTlsCtx(client); @@ -3005,7 +2896,7 @@ void UT_TLS_DTLS_CONSISTENCY_RFC6347_TC001() ASSERT_EQ(FRAME_TrasferMsgBetweenLink(server, client), HITLS_SUCCESS); uint8_t readData[MAX_RECORD_LENTH] = {0}; uint32_t readLen = MAX_RECORD_LENTH; - ASSERT_EQ(HITLS_Read(clientTlsCtx, readData, MAX_RECORD_LENTH, &readLen), HITLS_MSG_HANDLE_UNMATCHED_SEQUENCE); + ASSERT_EQ(HITLS_Read(clientTlsCtx, readData, MAX_RECORD_LENTH, &readLen), HITLS_REC_NORMAL_RECV_BUF_EMPTY); EXIT: HITLS_CFG_FreeConfig(tlsConfig); FRAME_FreeLink(client); diff --git a/testcode/sdv/testcase/tls/consistency/dtls12/test_suite_sdv_frame_dtls12_consistency.data b/testcode/sdv/testcase/tls/consistency/dtls12/test_suite_sdv_frame_dtls12_consistency.data index 93c17b75..c89e2d2c 100644 --- a/testcode/sdv/testcase/tls/consistency/dtls12/test_suite_sdv_frame_dtls12_consistency.data +++ b/testcode/sdv/testcase/tls/consistency/dtls12/test_suite_sdv_frame_dtls12_consistency.data @@ -1,39 +1,21 @@ UT_TLS_DTLS_CONSISTENCY_RFC5246_UNEXPETED_REORD_TYPE_TC001 UT_TLS_DTLS_CONSISTENCY_RFC5246_UNEXPETED_REORD_TYPE_TC001: -UT_TLS_DTLS_CONSISTENCY_RFC5246_SEQ_NUMBER_TC001 -UT_TLS_DTLS_CONSISTENCY_RFC5246_SEQ_NUMBER_TC001:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC5246_SEQ_NUMBER_TC001 UT_TLS_DTLS_CONSISTENCY_RFC5246_SEQ_NUMBER_TC001:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC5246_SEQ_NUMBER_TC002 -UT_TLS_DTLS_CONSISTENCY_RFC5246_SEQ_NUMBER_TC002:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC5246_SEQ_NUMBER_TC002 UT_TLS_DTLS_CONSISTENCY_RFC5246_SEQ_NUMBER_TC002:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC5246_SEQ_NUMBER_TC003 -UT_TLS_DTLS_CONSISTENCY_RFC5246_SEQ_NUMBER_TC003:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC5246_SEQ_NUMBER_TC003 UT_TLS_DTLS_CONSISTENCY_RFC5246_SEQ_NUMBER_TC003:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_TOOLONG_TC001 -UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_TOOLONG_TC001:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_TOOLONG_TC001 UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_TOOLONG_TC001:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_TOOLONG_TC002 -UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_TOOLONG_TC002:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_TOOLONG_TC002 UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_TOOLONG_TC002:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_TOOLONG_TC003 -UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_TOOLONG_TC003:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_TOOLONG_TC003 UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_TOOLONG_TC003:BSL_UIO_UDP @@ -58,15 +40,9 @@ UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_ZERO_TC006: UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_ZERO_TC007 UT_TLS_DTLS_CONSISTENCY_RFC5246_MSGLENGTH_ZERO_TC007: -UT_TLS_DTLS_CONSISTENCY_RFC5246_COMPRESSED_TC001 -UT_TLS_DTLS_CONSISTENCY_RFC5246_COMPRESSED_TC001:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC5246_COMPRESSED_TC001 UT_TLS_DTLS_CONSISTENCY_RFC5246_COMPRESSED_TC001:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC5246_COMPRESSED_TC002 -UT_TLS_DTLS_CONSISTENCY_RFC5246_COMPRESSED_TC002:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC5246_COMPRESSED_TC002 UT_TLS_DTLS_CONSISTENCY_RFC5246_COMPRESSED_TC002:BSL_UIO_UDP @@ -82,9 +58,6 @@ UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC001: UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC002 UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC002: -UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC003 -UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC003:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC003 UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC003:BSL_UIO_UDP @@ -94,117 +67,61 @@ UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC004: UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC005 UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC005: -UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC007 -UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC007:BSL_UIO_SCTP UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC007 UT_TLS_DTLS_CONSISTENCY_RFC5246_SIGNATURE_TC007:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC5246_CERTIFICATE_TC003 -UT_TLS_DTLS_CONSISTENCY_RFC5246_CERTIFICATE_TC003:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC5246_CERTIFICATE_TC003 UT_TLS_DTLS_CONSISTENCY_RFC5246_CERTIFICATE_TC003:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC5246_CERTIFICATE_TC004 -UT_TLS_DTLS_CONSISTENCY_RFC5246_CERTIFICATE_TC004: - -UT_TLS_DTLS_CONSISTENCY_RFC5246_VERSION_TC001 -UT_TLS_DTLS_CONSISTENCY_RFC5246_VERSION_TC001:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC5246_VERSION_TC001 UT_TLS_DTLS_CONSISTENCY_RFC5246_VERSION_TC001:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC001 -UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC001:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC001 UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC001:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC002 -UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC002:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC002 UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC002:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC003 -UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC003:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC003 UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC003:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC004 -UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC004:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC004 UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC004:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC005 -UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC005:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC005 UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC005:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC006 -UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC006:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC006 UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC006:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC007 -UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC007:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC007 UT_TLS_DTLS_CONSISTENCY_RFC5246_HELLO_REQUEST_TC007:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC6083_RETRANSMISSION_TC001 -UT_TLS_DTLS_CONSISTENCY_RFC6083_RETRANSMISSION_TC001: - UT_TLS_DTLS_CONSISTENCY_RFC6347_FINISH_TC001 UT_TLS_DTLS_CONSISTENCY_RFC6347_FINISH_TC001: UT_TLS_DTLS_CONSISTENCY_RFC6347_FINISH_TC002 UT_TLS_DTLS_CONSISTENCY_RFC6347_FINISH_TC002: -UT_TLS_DTLS_CONSISTENCY_RFC6347_FINISH_TC003 -UT_TLS_DTLS_CONSISTENCY_RFC6347_FINISH_TC003:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC6347_FINISH_TC003 UT_TLS_DTLS_CONSISTENCY_RFC6347_FINISH_TC003:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC6347_FINISH_TC004 -UT_TLS_DTLS_CONSISTENCY_RFC6347_FINISH_TC004:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC6347_FINISH_TC004 UT_TLS_DTLS_CONSISTENCY_RFC6347_FINISH_TC004:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC6347_DISORDER_TC001 -UT_TLS_DTLS_CONSISTENCY_RFC6347_DISORDER_TC001:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC6347_DISORDER_TC001 UT_TLS_DTLS_CONSISTENCY_RFC6347_DISORDER_TC001:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC6347_DISORDER_TC002 -UT_TLS_DTLS_CONSISTENCY_RFC6347_DISORDER_TC002:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC6347_DISORDER_TC002 UT_TLS_DTLS_CONSISTENCY_RFC6347_DISORDER_TC002:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC6347_APPDATA_TC001 -UT_TLS_DTLS_CONSISTENCY_RFC6347_APPDATA_TC001:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC6347_APPDATA_TC001 UT_TLS_DTLS_CONSISTENCY_RFC6347_APPDATA_TC001:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC6347_APPDATA_TC002 -UT_TLS_DTLS_CONSISTENCY_RFC6347_APPDATA_TC002:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC6347_APPDATA_TC002 UT_TLS_DTLS_CONSISTENCY_RFC6347_APPDATA_TC002:BSL_UIO_UDP -UT_TLS_DTLS_CONSISTENCY_RFC6347_CLIENT_HELLO_TC001 -UT_TLS_DTLS_CONSISTENCY_RFC6347_CLIENT_HELLO_TC001:BSL_UIO_SCTP - UT_TLS_DTLS_CONSISTENCY_RFC6347_CLIENT_HELLO_TC001 UT_TLS_DTLS_CONSISTENCY_RFC6347_CLIENT_HELLO_TC001:BSL_UIO_UDP @@ -229,9 +146,6 @@ UT_TLS_DTLS_CONSISTENCY_RFC8422_ECPOINT_TC001: UT_TLS_DTLS_CONSISTENCY_RFC8422_EXTENSION_MISS_TC001 UT_TLS_DTLS_CONSISTENCY_RFC8422_EXTENSION_MISS_TC001: -UT_DTLS_RFC6347_RECV_ALERT_AFTER_CCS_TC001 -UT_DTLS_RFC6347_RECV_ALERT_AFTER_CCS_TC001:BSL_UIO_SCTP - UT_DTLS_RFC6347_RECV_ALERT_AFTER_CCS_TC001 UT_DTLS_RFC6347_RECV_ALERT_AFTER_CCS_TC001:BSL_UIO_UDP diff --git a/testcode/sdv/testcase/tls/consistency/dtls12/test_suite_sdv_hlt_dtls12_consistency.c b/testcode/sdv/testcase/tls/consistency/dtls12/test_suite_sdv_hlt_dtls12_consistency.c index bec07d21..671e7a99 100644 --- a/testcode/sdv/testcase/tls/consistency/dtls12/test_suite_sdv_hlt_dtls12_consistency.c +++ b/testcode/sdv/testcase/tls/consistency/dtls12/test_suite_sdv_hlt_dtls12_consistency.c @@ -157,84 +157,4 @@ EXIT: HITLS_SESS_Free(session); HLT_FreeAllProcess(); } -/* END_CASE */ -static int32_t DtlsSctpUioWriteException(BSL_UIO *uio, const void *buf, uint32_t len, uint32_t *writeLen) -{ - int32_t ret; - static int32_t count = 0; - count++; - if (count == 1) { - ret = SctpDefaultWrite(uio, (uint8_t *)buf, len / 2, writeLen); - } else { - ret = SctpDefaultWrite(uio, (uint8_t *)buf, len, writeLen); - } - return ret; -} -/** -* @test SDV_TLS_DTLS_WRITE_APP_FAILED_TC001 -* @spec - -* @title The client and server receive the client Hello message after the connection establishment is complete. -* @precon nan -* @brief -* 1. Use the default configuration items to configure the client and server. Expected result 1. -* 2. A DTLS over SCTP connection is established between the client and server. Expected result 2. -* 3. Construct a app message and send it to the client. Check the server ret. Expected result 3. -* 4. Construct a app message and send it to the client. Check the server ret. Expected result 4. -* @expect -* 1. The initialization is successful. -* 2. The connection is set up successfully. -* 3. The server ret is HITLS_REC_ERR_IO_EXCEPTION. -* 4. The server ret is HITLS_SUCCESS. -* @prior Level 1 -* @auto TRUE -@ */ -/* BEGIN_CASE */ -void SDV_TLS_DTLS_WRITE_APP_FAILED_TC001(int version, int connType) -{ - if (connType == SCTP && !IsEnableSctpAuth()){ - return; - } - bool certverifyflag = true; - - HLT_Tls_Res *serverRes = NULL; - HLT_Tls_Res *clientRes = NULL; - HLT_Process *localProcess = NULL; - HLT_Process *remoteProcess = NULL; - - localProcess = HLT_InitLocalProcess(HITLS); - ASSERT_TRUE(localProcess != NULL); - remoteProcess = HLT_LinkRemoteProcess(HITLS, connType, 16790, true); - ASSERT_TRUE(remoteProcess != NULL); - - HLT_Ctx_Config *serverCtxConfig = HLT_NewCtxConfig(NULL, "SERVER"); - ASSERT_TRUE(serverCtxConfig != NULL); - - serverCtxConfig->isSupportClientVerify = certverifyflag; - - serverRes = HLT_ProcessTlsAccept(localProcess, version, serverCtxConfig, NULL); - ASSERT_TRUE(serverRes != NULL); - - HLT_Ctx_Config *clientCtxConfig = HLT_NewCtxConfig(NULL, "CLIENT"); - ASSERT_TRUE(clientCtxConfig != NULL); - - clientCtxConfig->isSupportClientVerify = certverifyflag; - - clientRes = HLT_ProcessTlsConnect(remoteProcess, version, clientCtxConfig, NULL); - ASSERT_TRUE(clientRes != NULL); - - ASSERT_TRUE(HLT_GetTlsAcceptResult(serverRes) == 0); - - HITLS_Ctx *ctx = serverRes->ssl; - BSL_UIO *uio = ctx->uio; - uio->method.write = DtlsSctpUioWriteException; - ASSERT_EQ(HLT_ProcessTlsWrite(localProcess, serverRes, (uint8_t *)"Hello World", strlen("Hello World")), HITLS_REC_ERR_IO_EXCEPTION); - ASSERT_EQ(HLT_ProcessTlsWrite(localProcess, serverRes, (uint8_t *)"Hello World2", strlen("Hello World2")), HITLS_SUCCESS); - uint8_t readBuf[1024] = {0}; - uint32_t readLen; - ASSERT_TRUE(HLT_ProcessTlsRead(remoteProcess, clientRes, readBuf, sizeof(readBuf), &readLen) == 0); - ASSERT_TRUE(readLen == strlen("Hello World2")); - ASSERT_TRUE(memcmp("Hello World2", readBuf, readLen) == 0); -EXIT: - HLT_FreeAllProcess(); -} /* END_CASE */ \ No newline at end of file diff --git a/testcode/sdv/testcase/tls/consistency/dtls12/test_suite_sdv_hlt_dtls12_consistency.data b/testcode/sdv/testcase/tls/consistency/dtls12/test_suite_sdv_hlt_dtls12_consistency.data index 26985ca4..0d22b9db 100644 --- a/testcode/sdv/testcase/tls/consistency/dtls12/test_suite_sdv_hlt_dtls12_consistency.data +++ b/testcode/sdv/testcase/tls/consistency/dtls12/test_suite_sdv_hlt_dtls12_consistency.data @@ -1,5 +1,2 @@ SDV_TLS_DTLS_CONSISTENCY_RFC5246_UNEXPETED_REORD_TYPE_TC001 tls12 -SDV_TLS_DTLS_CONSISTENCY_RFC5246_UNEXPETED_REORD_TYPE_TC001: - -SDV_TLS_DTLS_WRITE_APP_FAILED_TC001 SCTP -SDV_TLS_DTLS_WRITE_APP_FAILED_TC001:DTLS1_2:SCTP \ No newline at end of file +SDV_TLS_DTLS_CONSISTENCY_RFC5246_UNEXPETED_REORD_TYPE_TC001: \ No newline at end of file diff --git a/testcode/sdv/testcase/tls/consistency/tls13/test_suite_sdv_frame_tls13_consistency_rfc8446_cert.c b/testcode/sdv/testcase/tls/consistency/tls13/test_suite_sdv_frame_tls13_consistency_rfc8446_cert.c index 4e58d5cf..a6fd3a37 100644 --- a/testcode/sdv/testcase/tls/consistency/tls13/test_suite_sdv_frame_tls13_consistency_rfc8446_cert.c +++ b/testcode/sdv/testcase/tls/consistency/tls13/test_suite_sdv_frame_tls13_consistency_rfc8446_cert.c @@ -286,9 +286,9 @@ void UT_TLS_TLS13_RFC8446_CONSISTENCY_RECV_ZEROLENGTH_MSG_FUNC_TC008(void) HITLS_Config *config = HITLS_CFG_NewTLS13Config(); ASSERT_TRUE(config != NULL); - FRAME_LinkObj *client = FRAME_CreateLink(config, BSL_UIO_SCTP); + FRAME_LinkObj *client = FRAME_CreateLink(config, BSL_UIO_TCP); ASSERT_TRUE(client != NULL); - FRAME_LinkObj *server = FRAME_CreateLink(config, BSL_UIO_SCTP); + FRAME_LinkObj *server = FRAME_CreateLink(config, BSL_UIO_TCP); ASSERT_TRUE(server != NULL); HITLS_Ctx *clientTlsCtx = FRAME_GetTlsCtx(client); diff --git a/testcode/sdv/testcase/tls/consistency/tls13/test_suite_sdv_frame_tls13_consistency_rfc8446_pha.c b/testcode/sdv/testcase/tls/consistency/tls13/test_suite_sdv_frame_tls13_consistency_rfc8446_pha.c index c1a7a877..37160215 100644 --- a/testcode/sdv/testcase/tls/consistency/tls13/test_suite_sdv_frame_tls13_consistency_rfc8446_pha.c +++ b/testcode/sdv/testcase/tls/consistency/tls13/test_suite_sdv_frame_tls13_consistency_rfc8446_pha.c @@ -230,9 +230,9 @@ void UT_TLS_TLS13_RFC8446_CONSISTENCY_POSTHANDSHAKE_FUNC_TC018(void) // Apply for and initialize the configuration file config = HITLS_CFG_NewTLS13Config(); - client = FRAME_CreateLink(config, BSL_UIO_SCTP); + client = FRAME_CreateLink(config, BSL_UIO_TCP); ASSERT_TRUE(client != NULL); - server = FRAME_CreateLink(config, BSL_UIO_SCTP); + server = FRAME_CreateLink(config, BSL_UIO_TCP); ASSERT_TRUE(server != NULL); // Configure the client and server to support post-handshake extension @@ -283,9 +283,9 @@ void UT_TLS_TLS13_RFC8446_CONSISTENCY_POSTHANDSHAKE_FUNC_TC019(void) // Apply for and initialize the configuration file config = HITLS_CFG_NewTLS13Config(); - client = FRAME_CreateLink(config, BSL_UIO_SCTP); + client = FRAME_CreateLink(config, BSL_UIO_TCP); ASSERT_TRUE(client != NULL); - server = FRAME_CreateLink(config, BSL_UIO_SCTP); + server = FRAME_CreateLink(config, BSL_UIO_TCP); ASSERT_TRUE(server != NULL); // Configure the client to support the post-handshake extension diff --git a/testcode/sdv/testcase/tls/interface/test_suite_sdv_frame_tls_cm_1.c b/testcode/sdv/testcase/tls/interface/test_suite_sdv_frame_tls_cm_1.c index 9e5ce3f4..e712ca3b 100644 --- a/testcode/sdv/testcase/tls/interface/test_suite_sdv_frame_tls_cm_1.c +++ b/testcode/sdv/testcase/tls/interface/test_suite_sdv_frame_tls_cm_1.c @@ -458,9 +458,9 @@ void UT_TLS_CM_VERIFY_CLIENT_POST_HANDSHAKE_API_TC001(void) // Apply for and initialize the configuration file config = HITLS_CFG_NewTLS13Config(); - client = FRAME_CreateLink(config, BSL_UIO_SCTP); + client = FRAME_CreateLink(config, BSL_UIO_TCP); ASSERT_TRUE(client != NULL); - server = FRAME_CreateLink(config, BSL_UIO_SCTP); + server = FRAME_CreateLink(config, BSL_UIO_TCP); ASSERT_TRUE(server != NULL); // Configure the client and server to support post-handshake extension @@ -512,10 +512,10 @@ void UT_TLS_CM_REMOVE_CERTANDKEY_API_TC001(void) ret = HITLS_CFG_SetNoClientCertSupport(config, true); ASSERT_TRUE(ret == HITLS_SUCCESS); - client = FRAME_CreateLink(config, BSL_UIO_SCTP); + client = FRAME_CreateLink(config, BSL_UIO_UDP); ASSERT_TRUE(client != NULL); - server = FRAME_CreateLink(config, BSL_UIO_SCTP); + server = FRAME_CreateLink(config, BSL_UIO_UDP); ASSERT_TRUE(server != NULL); ret = HITLS_RemoveCertAndKey(client->ssl); diff --git a/testcode/sdv/testcase/tls/interface/test_suite_sdv_frame_tls_cm_1.data b/testcode/sdv/testcase/tls/interface/test_suite_sdv_frame_tls_cm_1.data index 7d8c7388..d36e8891 100644 --- a/testcode/sdv/testcase/tls/interface/test_suite_sdv_frame_tls_cm_1.data +++ b/testcode/sdv/testcase/tls/interface/test_suite_sdv_frame_tls_cm_1.data @@ -85,15 +85,9 @@ UT_TLS_HITLS_READ_WRITE_TC001:HITLS_VERSION_TLS12 UT_TLS_HITLS_READ_WRITE_TC001 UT_TLS_HITLS_READ_WRITE_TC001:HITLS_VERSION_TLS13 -UT_TLS_HITLS_CLOSE_TC001 -UT_TLS_HITLS_CLOSE_TC001:BSL_UIO_SCTP - UT_TLS_HITLS_CLOSE_TC001 UT_TLS_HITLS_CLOSE_TC001:BSL_UIO_UDP -UT_TLS_HITLS_CLOSE_TC002 -UT_TLS_HITLS_CLOSE_TC002:BSL_UIO_SCTP - UT_TLS_HITLS_CLOSE_TC002 UT_TLS_HITLS_CLOSE_TC002:BSL_UIO_UDP diff --git a/testcode/sdv/testcase/tls/interface_tlcp/test_suite_sdv_frame_cm_interface.c b/testcode/sdv/testcase/tls/interface_tlcp/test_suite_sdv_frame_cm_interface.c index dd8020ad..c84f2976 100644 --- a/testcode/sdv/testcase/tls/interface_tlcp/test_suite_sdv_frame_cm_interface.c +++ b/testcode/sdv/testcase/tls/interface_tlcp/test_suite_sdv_frame_cm_interface.c @@ -3334,7 +3334,7 @@ void UT_TLS_CM_InfoCb_API_TC001(void) HITLS_Config *config = HITLS_CFG_NewDTLS12Config(); ASSERT_TRUE(config != NULL); - FRAME_LinkObj *client = FRAME_CreateLink(config, BSL_UIO_SCTP); + FRAME_LinkObj *client = FRAME_CreateLink(config, BSL_UIO_UDP); ASSERT_TRUE(client != NULL); HITLS_Ctx *clientTlsCtx = FRAME_GetTlsCtx(client); ASSERT_TRUE(clientTlsCtx != NULL); diff --git a/tls/handshake/common/src/hs_common.c b/tls/handshake/common/src/hs_common.c index 09f119c1..73f0b431 100644 --- a/tls/handshake/common/src/hs_common.c +++ b/tls/handshake/common/src/hs_common.c @@ -361,10 +361,7 @@ int32_t HS_SetSctpAuthKey(TLS_Ctx *ctx) /* If the UIO_SctpAddAuthKey is added but not active, return HITLS_SUCCESS when the interface is invoked again */ - BSL_UIO_SctpAuthKey key = {0}; - key.authKey = authKey; - key.authKeySize = authKeyLen; - ret = BSL_UIO_Ctrl(ctx->uio, BSL_UIO_SCTP_ADD_AUTH_SHARED_KEY, (int32_t)sizeof(BSL_UIO_SctpAuthKey), &key); + ret = BSL_UIO_Ctrl(ctx->uio, BSL_UIO_SCTP_ADD_AUTH_SHARED_KEY, (int32_t)authKeyLen, authKey); /* Clear sensitive information */ BSL_SAL_CleanseData(authKey, DTLS_SCTP_SHARED_AUTHKEY_LEN); if (ret != BSL_SUCCESS) {